KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
There's a question on SO about "possible multiple enumerations" already, but this question is more specific. Please consider the following method, which takes an IEnumerable<string> as input and executes a given method against each of its elements: public static bool SomeMethod(IEnumerable<string> enumerable) { if (enumerable.IsNullOrEmpty()) { // throw exception. } else { return (enumerable.All(SomeBooleanMethod)); } } In the code above, IsNullOrEmpty is just an extension method which runs return (!ReferenceEquals(enumerable, null) || enumerable.Any()); The problem is that ReSharper is warning me about "Possible multiple enumerations of IEnumerable", and I really don't know if this can actually be a problem or not. I understand the meaning of the warning, but what could you really do in this situation if you really need to check and throw exception in case of nullity or emptyness?
Tags (comma-separated)
Save Edits
Cancel