To enhance the performance of the Any() call in LINQ, I’ve introduced the FastAny() method within the DotNetTips.Spargine.Extensions NuGet package. Employing it is as straightforward as using the Any() call with a predicate:
var result = people.FastAny(p => p.FirstName.Equals(firstName));
Benchmark Results
As indicated by the benchmark, FastAny() from Spargine exhibits a 1.08 times improvement in performance. Additionally, this method incorporates a null check for the collection.
Pick up any books by David McCarter by going to Amazon.com: http://bit.ly/RockYourCodeBooks
Make a one-time donation
Make a monthly donation
Make a yearly donation
Choose an amount
Or enter a custom amount
Your contribution is appreciated.
Your contribution is appreciated.
Your contribution is appreciated.
DonateDonate monthlyDonate yearlyIf you liked this article, please buy David a cup of Coffee by going here: https://www.buymeacoffee.com/dotnetdave
© The information in this article is copywritten and cannot be preproduced in any way without express permission from David McCarter.
Discover more from dotNetTips.com
Subscribe to get the latest posts sent to your email.


