Hi folks,
in the System.Linq
namespace, we can now extend our IEnumerable
's to have theAny()
and Count()
extension methods.
I was told recently that if i want to check that a collection contains 1 or more items inside it, I should use the .Any()
extension method instead of the .Count() > 0
extension method because the .Count()
extension method has to iterate through all the items.
Secondly, some collections have a property (not an extension method) that is Count
or Length
. Would it be better to use those, instead of .Any()
or .Count()
?
yea / nae ?