How do I clone a generic list in C#?

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

猜你喜欢

转载自www.cnblogs.com/kevin1988/p/9023294.html