1
A
回答
4
另一种方法是:
PropertyInfo info = obj.GetType().GetProperty("PropertyNameToFind");
if (info != null)
{
// Property exists in this type...
}
1
给看看System.Reflection.PropertyInfo类。
下面是使用反射示例用法
using System.Reflection; // reflection namespace
// get all public static properties of MyClass type
PropertyInfo[] propertyInfos;
propertyInfos = typeof(MyClass).GetProperties(BindingFlags.Public | BindingFlags.Static);
// sort properties by name
Array.Sort(propertyInfos, delegate(PropertyInfo propertyInfo1, PropertyInfo propertyInfo2)
{ return propertyInfo1.Name.CompareTo(propertyInfo2.Name); });
// write property names
foreach (PropertyInfo propertyInfo in propertyInfos) {
Console.WriteLine(propertyInfo.Name);
}
相关问题
- 1. C#参数化属性的后期绑定
- 2. COM +后期绑定C#4.0
- 3. C#Excel 2007后期绑定
- 4. C#中的后期绑定#
- 5. 在actionscript中绑定存在属性
- 6. 将非属性绑定到datagrid列DataField?
- 7. 绑定Button.Enabled属性在C#dll
- 8. 绑定属性parent属性
- 9. 如何将DataTrigger绑定到非绑定属性?
- 10. 绑定属性
- 11. 如何访问后期绑定的嵌套属性和方法?
- 12. 代码背后的绑定属性
- 13. MVC绑定到转换后的属性
- 14. java多态性后期绑定规则
- 15. 数据绑定期间未绑定继承的属性
- 16. 与属性绑定在Silverlight
- 17. 自定义属性没有绑定的绑定属性
- 18. 数据绑定属性C#WPF
- 19. 父属性绑定
- 20. 绑定HTML属性
- 21. Silverlight属性绑定
- 22. QML属性绑定
- 23. Java属性绑定
- 24. wcf绑定属性
- 25. XAML绑定属性
- 26. MouseDragElementBehavior绑定属性
- 27. Java属性绑定
- 28. C中发布后期绑定对象#
- 29. C中单词的后期绑定#
- 30. C#后期绑定卸载DLL的