首页 新闻 会员 周边

关于IList<T>

0
[已关闭问题]

能不能把一个IList <T>中的数据放到拷贝到另外一个Ilist <T> ,对象都是一样的

yuankun的主页 yuankun | 初学一级 | 园豆:25
提问于:2009-05-31 21:29
< >
分享
其他回答(1)
0

        public static void ListCopy(IList<T> src, IList<T> dest)
        {
            if (src == null)
            {
                throw new System.ArgumentNullException("src", "src is null!");
            }

            if (dest == null)
            {
                throw new System.ArgumentNullException("dest", "dest is null!");
            }

            dest.Clear();

            foreach (T item in src)
            {
                dest.Add(item);
            }

        }

eaglet | 园豆:17139 (专家六级) | 2009-06-01 07:36
0

深拷贝吗?

有个简单的方法 

IList<string> list1 = new List<string>(); //源list

IList<string> list2 = new List<string>(list2); //目的list

kiminozo | 园豆:245 (菜鸟二级) | 2009-06-01 08:47
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册