码迷,mamicode.com
首页 > Windows程序 > 详细

How do I clone a generic list in C#?

时间:2018-05-11 12:42:29      阅读:182      评论:0      收藏:0      [点我收藏+]

标签:gen   class   one   ati   listt   ons   c#   toc   eric   

static class Extensions
{
    public static IList<T> Clone<T>(this IList<T> listToClone) where T: ICloneable
    {
        return listToClone.Select(item => (T)item.Clone()).ToList();
    }
}

How do I clone a generic list in C#?

标签:gen   class   one   ati   listt   ons   c#   toc   eric   

原文地址:https://www.cnblogs.com/kevin1988/p/9023294.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!