Nope. The cost of the code will always be more than any possible gain from growth, which is substantially equal to zero. Do not forget that the whole LINQ point is a chain of such expressions, so you are most likely using Any either with a predicate or with its own set of filters, etc. Before.
In which case, when would you use Any as an alternative to Count ? Even the optimization of Count has a very subtle use of IMO - if you do Count() inside some logic that expects IEnumerable as a parameter, you are probably mistaken - at least you tend to list the enumerated several times, which is likely to break that or will kill your performance: D
Do not forget that as soon as you do something in this enumerated array, you have lost the "array", for example. categories.Where(i => i.Name.StartsWith("Hello")).Count() will not use the abbreviation.
And, of course, the cost of an enumerator on any empty enumerable is likely to be quite free. An enumerator is just a simple structure, and there will also be no costly initialization in the array.
source share