When calling Any() on a null object, it throws an ArgumentNullException in C#. If the object is null, there definitely aren\'t \'any\', and it should probably return false.
As others have already mentioned, Any
checks whether or not a sequence contains elements. It does not prevent you from passing null
values(what might the bug in the first place).
Every extension method in Enumerable class throws an an ArgumentNullException if the source
is null
. Throwing ArgumentNullExceptions
in extensions actually is good practise.