I currently have multiple lists and I wish to dynamically create class instances based on the data in this lists.
The class is as fallows:
public class itemFav
{
public string FavsGTS { get; set; }
public string FavsGPICS { get; set; }
public string FavsRNS { get; set; }
public string FavsPIS { get; set; }
public string FavsIsOns { get; set; }
}
I'm not sure if it's possible or how its properly done, but I wish to do something like this:
public int itemCount { get; set; }
public dynamic items = new List<dynamic>();
foreach(string item in list1)
{
itemCount = 0 + items.Count;
//Here it would create the instances.
itemFav instance+itemCount = new itemFav()
{
FavsGTS = list1[itemCount],
FavsGPICS = list2[itemCount],
FavsRNS = list3[itemCount],
FavsPIS = list4[itemCount],
FavsIsOns = list5[itemCount]
};
items.Add(instance+itemCount);
}
The instance+itemCount is what I would like to know if there is a way to do. Or what is the correct way to dynamically create class instances.