我似乎无法弄清楚如何填充子类......
这些是我的课程:
public class Item
{
public Meta meta { get; set; }
public Items[] objects { get; set; }
}
public class Meta
{
public int limit { get; set; }
public object next { get; set; }
public int offset { get; set; }
public object previous { get; set; }
public int total_count { get; set; }
}
public class Items
{
public Additionalprices additionalPrices { get; set; }
public string barcode { get; set; }
public Category category { get; set; }
public int categoryPosition { get; set; }
public string cdate { get; set; }
public DateTime ctime { get; set; }
public DateTime ctimeOnServer { get; set; }
public Dimensions dimensions { get; set; }
public string entityType { get; set; }
public object imageURL { get; set; }
public object[] imageURLs { get; set; }
public string longDesc { get; set; }
public string manufacturer { get; set; }
public int minQty { get; set; }
public DateTime mtime { get; set; }
public DateTime mtimeOnServer { get; set; }
public int multQty { get; set; }
public string name { get; set; }
public int objID { get; set; }
public string owner { get; set; }
public string resource_uri { get; set; }
public string sku { get; set; }
public object thumbnailURL { get; set; }
public object[] thumbnailURLs { get; set; }
public string unitPrice { get; set; }
public string uuid { get; set; }
public Variant[] variants { get; set; }
}
我想添加一些虚拟对象...
这是我的代码...
// Create a dummy Category
HandShake_Classes.Category categoryToUpload = new HandShake_Classes.Category();
categoryToUpload.name = "Trev Category";
// Create a dummy Item
HandShake_Classes.Item itemToUpload = new HandShake_Classes.Item();
// THIS IS WHERE MY PROBLEM IS...
itemToUpload.objects = new HandShake_Classes.Items();
// THE ERROR I AM GETTING IS Error 2 Cannot implicitly convert type 'handshake.com.HandShake_Classes.Items' to 'handshake.com.HandShake_Classes.Items[]'
// Only populate required fields at the moment
itemToUpload.objects[0].sku = "ljklj";
itemToUpload.objects[0].name = "Trevs Product";
itemToUpload.objects[0].unitPrice = "1.23";
itemToUpload.objects[0].minQty = 1;
itemToUpload.objects[0].category = categoryToUpload;
我只是无法弄清楚我认为如何定义 Items[]
谁能指出我正确的方向?
谢谢