开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜