【发布时间】:2021-01-25 16:46:46
【问题描述】:
我试图在没有参考的情况下克隆 List
无法从 'System.Collections.Generic.List
' 转换为 'System.Collections.Generic.IEnumerable >
这是我想要运行的代码:
newList = new List<List<byte[]>>(oldList).ToArray();
这是否有效,还是有其他解决方案?
【问题讨论】:
-
我也这么认为:newList = (List
)oldList.ToList(); -
List<byte[]>不是List<List<byte[]>>。具体来说,您使用的List constructor 需要IEnumerable<T>,根据您的代码,在本例中为IEnumerable<List<byte[]>>。虽然我不确定为什么newList = oldList.ToList();不适合这种情况。
标签: c#