//class1
public class class1
{
public string Name1 { get; set; }
public int ID1 { get; set; }
}
//class2
public class class2
{
public string Name2 { get; set; }
public int ID2 { get; set; }
public class1 ctx { get; set; }
}
//MyClass
public class MyClass
{
public MyClass()
{
c2 = new List<class2>();
}
public string Name0 { get; set; }
public int ID0 { get; set; }
public class1 c1 { get; set; }
public List<class2> c2 { get; set; }
}
//Main
public static void Main()
{
var listMyClass = new List<MyClass>()
{
new MyClass()
{
Name0 = "Hello",
ID0 = 77,
c1 = new class1
{
Name1 = "I'm the first class",
ID1 = 1
},
c2 = new List<class2>
{
new class2
{
ID2 = 2
}
,
new class2
{
ID2 = 10000,
Name2 = "Pickles",
ctx = new class1()
{
ID1 = 11,
Name1 = "sss"
}
}
}
}
} ;
}
Hi, i want to transfer this list of Myclass (listMyClass ) to Datatable using reflection. Thanks.
Aucun commentaire:
Enregistrer un commentaire