小编EBE*_*LLO的帖子

C#Reflection - 获取没有字符串的PropertyInfo

我有一个房产Myclass:

public class MyClass{    
    public string FirstName {get;set;}
}
Run Code Online (Sandbox Code Playgroud)

如何在没有字符串的情况下获得PropertyInfo(使用GetProperty("FirstName"))?

今天我用这个:

PropertyInfo propertyTitleNews = typeof(MyClass).GetProperty("FirstName");
Run Code Online (Sandbox Code Playgroud)

有没有这样的使用方法:

PropertyInfo propertyTitleNews = typeof(MyClass).GetProperty(MyClass.FirstName);
Run Code Online (Sandbox Code Playgroud)

c# reflection

2
推荐指数
1
解决办法
1426
查看次数

标签 统计

c# ×1

reflection ×1