Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
您可以为此使用 LINQ 选择:
var enumerableOfU = collectionOfT.Select(t => new U(t));
如果要枚举多次,enumerableOfU则应在..ToList().ToArray()Select
enumerableOfU
.ToList()
.ToArray()
Select
请注意,这在内部仍然使用循环,但您不必自己编写。