C# List数组创建

List> list = new List>();
            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 str = new List();
                str.Add(name);
                str.Add(m_value);

                list.Add(str);
            }
 
  

C# List数组创建_第1张图片


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++;
            }


 
  

                            
                        
                    
                    
                    

你可能感兴趣的:(c#)