Resolve value in C#/.net 2.0
Is there a way to resolve values in a class structure using some xpath-style resolver?
Exampel in code:
string name = Order.Customer.Firstname;
What i would like to do is something like this:
string name = (string)X.Resol开发者_开发问答ve(Order, "Customer.Firstname");
Is there a way to do this in C#/.net 2.0
You could use Reflection to get out the properties and members of a type. Look at the MSDN page for Type.GetProperty
to get started.
That method would give you a PropertyInfo
which you can use to query the datatype of the property and to get and set it's value.
精彩评论