利用反射即可实现你所需要的功能。请看开源工具,反编译.NET程序集的工具:http://www.aisto.com/roeder/dotnet/私有声明都可以检索,何况公有类型。

解决方案 »

  1.   

    假设你的对象是obj,你希望比较的类型为MyType,你的数组是array 代码如下using System.Reflection;....Type dataType = obj.GetType();
    FieldInfo[] fields = dataType.GetFields( BindingFlags.Instance|BindingFlags.Public );
    foreach(FieldInfo field in fields)
    {
      if(field.FieldType == typeof(MyType){
         //add to your array...
         array.Add(field.GetValue(obj));
      }
    }
      

  2.   

    using System.Reflection;
    如上面的同志们说的