But when get B access field, where there is a problem,
Public class A
{
Public B B=new B ();
}
Public class B
{
Public string message1="";
Public string message2="";
}
Var t=typeof (A);
Var m=t.G etMembers ();
M. ll (member=& gt;
{
If (member. The Name. The ToUpper ()=="B")
{
Var fd=member. GetType ();
Fd. The GetFields ()
All (f=& gt;
{
If (motor ame. The Contains (" message1 "))
{
Console. WriteLine (" message1 ");
}
return true;
});
}
return true;
});
CodePudding user response:
Subclasses must mean should not B should inherit A? I am in you didn't see this inheritance