比如,list<T> t=new list<T>();
      t.add(T1);
      t.add(T2);
list<list<T>> x=new list<list<T>>();
x.add(t);
这样可以吗?!就是一个LIST包含多个“包含某个类的LIST”。

解决方案 »

  1.   

    没有任何问题!被包含的那个<list>也是一个元素 <list>就可用包含它 你把里面那个<list>当做一个对象看 问题就明了了......
      

  2.   

    可以的。list<>不也是类型吗?T表示的是类型
      

  3.   


    public List<T> CreateList<T>() where T : new()
            {
                List<T> t = new List<T>();
                t.Add(new T());
                t.Add(new T());
                List<List<T>> x = new List<List<T>>();
                x.Add(t);            return t;
            }
      

  4.   


    更正:
    public List<List<T>> CreateList<T>() where T : new()
            {
                List<T> t = new List<T>();
                t.Add(new T());
                t.Add(new T());
                List<List<T>> x = new List<List<T>>();
                x.Add(t);            return x;
            }
      

  5.   

    可以的,这是泛型,list<T> 也可以当T来使用的
      

  6.   

    public static List<object> SelectKeylogger(string[] splits, string[] strNum, string[] strData)
            {
                //存储查询的键盘记录信息
                List<KeyloggerInfo> listKeyInfo = new List<KeyloggerInfo>();
                List<object> listObj = new List<object>();
                int sumData = Convert.ToInt32(strNum[0]);//总数据条数
                int pageData = 20;//每页显示的条数
                int pageSum = sumData / pageData;//得到总页数
                int pages = sumData % 20;
                if (pages != 0)
                {
                    pageSum++;
                }
                string[] strInfo = null;
                int index = 0;
                for (int j = 0; j < strData.Length - 1; j++)
                {
                    strInfo = strData[j].ToString().Split(splits, StringSplitOptions.None);
                    KeyloggerInfo keyInfo = new KeyloggerInfo();
                    keyInfo.Mid = Convert.ToInt32(strNum[4]);
                    keyInfo.Keylogger = strInfo[index];
                    index++;
                    keyInfo.CombiKey = strInfo[index];
                    for (int i = 0; i < keyInfo.CombiKey.Length; i++)
                    {
                        if (keyInfo.CombiKey.Substring(i, 1) == "1")
                        {
                            if (i == 0)
                            {
                                keyInfo.Keylogger += "+Alt";
                            }
                            else if (i == 1)
                            {
                                keyInfo.Keylogger += "+Ctrl";
                            }
                            else if (i == 2)
                            {
                                keyInfo.Keylogger += "+Shift";
                            }
                            else if (i == 3)
                            {
                                keyInfo.Keylogger += "+Windows";
                            }
                        }
                    }
                    index++;
                    keyInfo.DateTime = Convert.ToDateTime(strInfo[index]).ToString("yyyy-MM-dd HH:mm:ss");
                    index++;
                    keyInfo.Applic = strInfo[index];
                    index++;
                    keyInfo.K_userName = strInfo[index];
                    index++;
                    keyInfo.K_agentName = SelectAgentByMid(keyInfo.Mid);
                    keyInfo.PcName = SelectPcName(keyInfo.Mid);
                    listKeyInfo.Add(keyInfo);
                    index = 0;
                    strInfo = null;
                }
                listObj.Add(pageSum);
                listObj.Add(listKeyInfo);
                return listObj;
            }