با سلام خدمت دوستان
از کلاس تو در توو استفاده می کنم خطا میده بصورت زیر:
public class ItemsOfQuestions
{
public string item_title { get; set; }
public Byte item_type { get; set; }
public string item_image { get; set; }
public Int16 item_grade { get; set;}
}
public class Questins_With_Items
{
public string question_title { get; set; }
public List<ItemsOfQuestions> list_items { get; set; }
}
بصورت زیر استفاده میکنم :
List<ItemsOfQuestions> itemlist = new List<ItemsOfQuestions>();
Questins_With_Items qwi = new Questins_With_Items();
for (int i = 0; i < 5; i++)
{
ItemsOfQuestions ioq = new ItemsOfQuestions();
ioq.item_title = "item"+i.ToString();
ioq.item_type = 0;
ioq.item_image = "";
ioq.item_grade = (Int16)i;
itemlist.Add(ioq);
}
qwi.question_title = "سوال اول";
qwi.list_items.Add(itemlist);
خطای:
Error 1 The best overloaded method match for 'System.Collections.Generic.List<graph1.ViewModels.ItemsOfQuestions>.Add(graph1.ViewModels.ItemsOfQuestions)' has some invalid arguments
Error 2 Argument 1: cannot convert from 'System.Collections.Generic.List<graph1.ViewModels.ItemsOfQuestions>' to 'graph1.ViewModels.ItemsOfQuestions'
علت چیه لطفا راهنمایی کنید ممنون .با تشکر
کد ها تون خوانا نیست
لطفا از کلید Code در ادیتور برای درج کد استفاده کنید
public class ItemsOfQuestions
{
public string item_title { get; set; }
public Byte item_type { get; set; }
public string item_image { get; set; }
public Int16 item_grade { get; set;}
}
public class Questins_With_Items
{
public string question_title { get; set; }
public List<ItemsOfQuestions> list_items { get; set; }
}
بصورت زیر استفاده میکنم :
List<ItemsOfQuestions> itemlist = new List<ItemsOfQuestions>();
Questins_With_Items qwi = new Questins_With_Items();
for (int i = 0; i < 5; i++)
{
ItemsOfQuestions ioq = new ItemsOfQuestions();
ioq.item_title = "item"+i.ToString();
ioq.item_type = 0;
ioq.item_image = "";
ioq.item_grade = (Int16)i;
itemlist.Add(ioq);
}
qwi.question_title = "سوال اول";
qwi.list_items.Add(itemlist);
هیچ کاربری تا کنون از این پست تشکر نکرده است
با ما تماس بگیرید تا در این مسیر همراهتان باشیم :)