IEnumerable的是空的?的是、IEnumerable

由网友(偷走你的心)分享简介:我知道它可能不事关/影响大部分的性能,但是我讨厌得到的想法的的IEnumerable 和做 .Count之间的() 。是否有一个的IsEmpty 或 NotEmpty 或某种功能? (类似于STL空())I know it probably doesnt matter/affect performance for t...

我知道它可能不事关/影响大部分的性能,但是我讨厌得到的想法的的IEnumerable 和做 .Count之间的() 。是否有一个的IsEmpty NotEmpty 或某种功能? (类似于STL空())

I know it probably doesnt matter/affect performance for the most part but I hate the idea of getting an IEnumerable and doing .Count(). Is there a IsEmpty or NotEmpty or some function? (similar to stl empty())

推荐答案

您想要的 IEnumerable.Any()扩展方法(.Net框架3.5及以上)。它避免了计算过的元素。

You want IEnumerable.Any() extension method (.Net Framework 3.5 and above). It avoids counting over the elements.

阅读全文

相关推荐

最新文章