首页  编辑  

获得类中的方法、字段和属性

Tags: /C#/RTTI/   Date Created:

using System . Reflection;

Type vType = GetType();

if (vType != null)

{

    MethodInfo [] vMethodInfos = vType . GetMethods();

    foreach ( MethodInfo vMethodInfo in vMethodInfos)

       textBox1 . AppendText(vMethodInfo . Name + "\r\n" );

    FieldInfo [] vFieldInfos = vType . GetFields();

    foreach ( FieldInfo vFieldInfo in vFieldInfos)

       textBox1 . AppendText(vFieldInfo . Name + "\r\n" );

    PropertyInfo [] vPropertyInfos = vType . GetProperties();

    foreach ( PropertyInfo vPropertyInfo in vPropertyInfos)

       textBox1 . AppendText(vPropertyInfo . Name + "\r\n" );

}