List.All()和List.TrueForAll()之间的区别 [英] Difference between List.All() and List.TrueForAll()
问题描述
在List
上进行操作时,.All()
和.TrueForAll()
之间是否存在实际差异?我知道.All()
是IEnumerable
的一部分,那么为什么要添加.TrueForAll()
?
来自 List<T>.TrueForAll
的文档:
支持:4、3.5、3.0、2.0
因此它是在之前 Enumerable.All
添加的.
对于其他许多List<T>
方法也是如此,这些方法的工作方式与LINQ方法类似.请注意,ConvertAll
有所不同,因为它具有了解的优势,即它正在处理List<T>
并创建List<TResult>
,因此可以预先分配所需的内容.>
Is there a practical difference between .All()
and .TrueForAll()
when operating on a List
? I know that .All()
is part of IEnumerable
, so why add .TrueForAll()
?
From the docs for List<T>.TrueForAll
:
Supported in: 4, 3.5, 3.0, 2.0
So it was added before Enumerable.All
.
The same is true for a bunch of other List<T>
methods which work in a similar way to their LINQ counterparts. Note that ConvertAll
is somewhat different, in that it has the advantage of knowing that it's working on a List<T>
and creating a List<TResult>
, so it gets to preallocate whatever it needs.
这篇关于List.All()和List.TrueForAll()之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!