结构为
public class UNIDEVICE_Ext
    {
        public string szPicUrl;//图片地址;
        public string szPicUrlExt;//图片地址多张图;
        public string szDevice;//房间设施;
    }
如何获得结构的成员,调用什么方法?这个问题应该给不难 我找不到那个方法,求高手赐教

解决方案 »

  1.   

    跟类一样啊,new一个干后就可以访问了呀
      

  2.   

    List<UNIDEVICE_Ext> list=查询数据取出所有信息
    用list存储的
      

  3.   

    new 之后get set不就可以了吗?
      

  4.   

    利用反射(Reflection)实现:
    Type myObjectType = typeof(UNIDEVICE_Ext);
    System.Reflection.FieldInfo[] fieldInfo = myObjectType.GetFields();
    foreach (System.Reflection.FieldInfo info in fieldInfo)
    {
        Console.WriteLine(info.Name);
    }
    另外,在 C# 代码中推荐使用 Carmel 而不是匈牙利命名规范。
      

  5.   


    class Program
        {
            static void Main(string[] args)
            {
                UNIDEVICE_Ext obj1 = new UNIDEVICE_Ext { szDevice = "aaa", szPicUrl = "bbb", szPicUrlExt = "ccc" };
                Type type = obj1.GetType();            FieldInfo[] fileds = type.GetFields();            Dictionary<string, string> filedValueMap = new Dictionary<string, string>();
                foreach (FieldInfo fi in fileds)
                {
                    filedValueMap.Add(fi.Name, fi.GetValue(obj1) as string);
                }            foreach (var keyval in filedValueMap)
                    Console.WriteLine("{0}:{1}", keyval.Key, keyval.Value);            Console.ReadLine();
            }
        }    public class UNIDEVICE_Ext
        {
            public string szPicUrl;//图片地址;
            public string szPicUrlExt;//图片地址多张图;
            public string szDevice;//房间设施;
        }