my code like below:
public static void Main()
{
B i=new B();
MemberInfo[] mis = i.GetType().GetMembers();
if (mis.FirstOrDefault(c => c.Name == "a") != null)
{
MemberInfo mi = mis.FirstOrDefault(c => c.Name == "a");
// Now I want to access member of a via mi
}
}
public class A
{
public int i { get; set; }
public void test() { }
}
public class B
{
public A a { get; set; }
public B()
{
a = new A();
}
}
I declared class A and class B, and got MemberInfo about b.a
. Now Can I get a's member via class MemberInfo ?
Aucun commentaire:
Enregistrer un commentaire