如何初始化一个类中某个属性的数组,而该属性是另一个类。
UserResponse res = new UserResponse()
{
//array has to be initialized in this block
Products = new Inventory[2] { }
};
public class UserResponse
{
public UserResponse();
public Inventory[] Products { get; set; }
}
public class Inventory
{
public Inventory();
public string Type { get; set; }
public string Status { get; set; }
}
如何在同一块中初始化大小为2的数组。