我想获取特定属性的PropertyInfo.我可以用:
foreach(PropertyInfo p in typeof(MyObject).GetProperties())
{
if ( p.Name == "MyProperty") { return p }
}
Run Code Online (Sandbox Code Playgroud)
但必须有办法做类似的事情
typeof(MyProperty) as PropertyInfo
Run Code Online (Sandbox Code Playgroud)
在那儿?还是我坚持做一个类型不安全的字符串比较?
干杯.