开发者

Anonymous object properties by string?

How can I开发者_Go百科 instantiate an anonymous object while passing the propertynames and values as string?

new With { .SomeProperty = "Value" }

new With { ".SomeProperty" = "Value" } //something like this? :)


There's no easy way to do this in VB.net. The JIT compiler doesn't keep the method names intact in the MSIL code, only in the metadata.

You can do this using the System.Reflection namespace and searching the metadata for a method by the name passed. It's fairly expensive, though.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜