日期:2014-05-17  浏览次数:20765 次

遍历结构体,有数组时不对,为什么
    结构体
struct BLC
{
  int a;
   int b;
   [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
   int[] cc;
}                
遍历
           Type type = typeof(BLC);
                foreach (FieldInfo mi in type.GetFields(BindingFlags.Public | BindingFlags.Instance))
                {
                        stest += mi.Name. + "." + mi.GetValue(blc);
                }

前面的a,b都Ok,可到了cc里,name =System.int[] 没有value。
请高手指教

------解决方案--------------------
用这个:
mi.GetValue(blc) is Array

别的看我的代码。