如何在 Windows Store App 中使用 C# 中的反射仅获取 public 属性
How to get only public property using reflection in C# in Windows Store App
我正在使用
typeof(ClassName).GetRuntimeProperties()
此方法将显示所有属性。你如何从没有绑定标志的 class 中只得到 public 属性,任何可能的方法请告诉我。
IEnumerable<PropertyInfo> properties =
typeof(TClass)
.GetRuntimeProperties()
.Where( pi => pi.CanRead && pi.GetGetMethod().IsPublic );
我正在使用
typeof(ClassName).GetRuntimeProperties()
此方法将显示所有属性。你如何从没有绑定标志的 class 中只得到 public 属性,任何可能的方法请告诉我。
IEnumerable<PropertyInfo> properties =
typeof(TClass)
.GetRuntimeProperties()
.Where( pi => pi.CanRead && pi.GetGetMethod().IsPublic );