use  Type.GetFields Method, you might also need to use BindingFlags.NonPublic flag, then use FieldInfo.Nameseehttp://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemTypeClassGetFieldsTopic2.asp

解决方案 »

  1.   

    假设你的类为ClassABC, abc是你该类的实例
    Type t = typeof(ClassABC);
    MemberInfo [] meminfo = typeof(ClassABC).GetMembers();
    foreach (MemberInfo nextMem in meminfo)
    {
       得到的是你的成员的集合,如果只想得到某一类成员,看==下面
       在这里输入你想要做的事情
       比如如果是txtNew怎么办等等
       可以用nextMem.Name,    nextMem.FullName,     nextMem.NameSpace等得到各种类的信息
    }==========================================================================
    如果是域
    FieldInfo [] fin_ClassABC=abc.GetTypes().GetFields();

    FieldInfo [] fin_ClassABC=typeof(ClassABC).GetFields();如果是方法
    MethodInfo [] min_ClassABC=abc.GetTypes().GetMethods();
    MethodInfo [] min_ClassABC=typeof(ClassABC).GetMethods();如果是属性
    PropertyInfo [] pin_ClassABC=abc.GetTypes().GetProperties();
    PropertyInfo [] pin_ClassABC=typeof(ClassABC).GetProperties();