C# List数组创建

来源:互联网 发布:日内 知乎 编辑:程序博客网 时间:2024/06/02 04:58

List<List<object>> list = new List<List<object>>();            Type t1 = typeof(AdminModel);            PropertyInfo[] propertys1 = t1.GetProperties();            foreach (PropertyInfo pi in propertys1)            {                string name = pi.Name;                object m_value = t1.GetProperty(name).GetValue(M_Model, null);                List<object> str = new List<object>();                str.Add(name);                str.Add(m_value);                list.Add(str);            }



Type t1 = typeof(AdminModel);            PropertyInfo[] propertys1 = t1.GetProperties();            string[,] str = new string[propertys1.Length, 2];            int _i = 0;            foreach (PropertyInfo pi in propertys1)            {                string name = pi.Name;                object m_value = t1.GetProperty(name).GetValue(M_Model, null);                str[_i, 0] = name.ToString();                str[_i, 1] = m_value.ToString();                _i++;            }


                                             
0 0