I am pleased to announce the new release (v2022.6.11.14) of Spargine on November 14th, 2022, my open-source projects, and NuGet packages for .NET 6 & 7. I have added new classes, methods, benchmarks, and unit tests! I use these in all the projects I work on, including many in production! I hope you will check them out and let me know what you would like added.
GitHub: https://github.com/RealDotNetDave/dotNetTips.Spargine/releases
NuGet: http://bit.ly/dotNetDaveNuGet
This release includes performance changes too. All the performance data for these assemblies can be found on GitHub. I always seek help with these projects, especially writing more unit tests. If you would like to help, please email me at dotnetdave@live.com.
Enumerable Extensions
Below are extension methods for IEnumerable and IEnumerable<T> collections that haven’t been previously documented from the DotNetTips.Spargine.Extensions namespace.
Count(IEnumerable): int– Counts the number of items in a collection.FastAny<T>(IEnumerable<T>, Func<T, bool>): bool– Determines if any items exist in a collection based on the predicate.FastCount<T>(IEnumerable<T>): long– Counts the number of items in a collection.FastCount<T>(IEnumerable<T>, Func<T, bool>): long– Counts the number of items in aIEnumerable<T>collection using a predicate.FirstOrDefault<T>(IEnumerable<T>, T): T– Returns the first items in a collection or a default object.FirstOrDefault<T>(IEnumerable<T>, Func<T, bool>, T): T– Returns the first items in a collection or a default object using a predicate.FirstOrNull<T>(IEnumberable<T>, Func<T, bool>): T?– Finds the first item in the collection or a null using a predicate.IndexOf<T>(IEnumerable<T>, T): int– Returns the index of an item in the collection.IndexOf<T>(IEnumerable<T>, T, IEqualityComparer<T>): int– Returns the index of an item in the collection using a comparer.IsNullOrEmpty(IEnumerable): bool– Determines whether a collection is null or empty.Join(IEnumerable<object>, [string]): string– Converts a collection to a string using a separator.OrderBy<T>(IEnumerable<T>, string): IEnumerable<T>– Orders a collection based on a sort expression.OrderByOrdinal<T>(IEnumerable<T>, Func<T, string>): IOrderedEnumerable<T>– Orders a collection by usingStringComparer.Ordinal.Page<T>(IEnumerable<T>, int): IEnumerable<IEnumerable<T>>– Converts a collection into separate collections based on page size.PickRandom<T>(IEumerable<T>): T– Picks a random item from a collection.StartsWith<T>(IEnumerable<T>, IEnumerable<T>): bool– Determines if the first collection starts with the second collection.StructualSequenceEqual<T>(IEnumerable<T>, IEnumerable<T>): bool– Determines if two collection sequences are equal.ToCollection<T>(IEnumerable<T>): Collection<T> - Converts an IEnumerable<T>collection to a Spargine Collection.ToImmutable<T>(IEnumerable<T>): ImmutableList<T> - Converts an IEnumerable<T>collection to an ImmutableList.ToLinkedList<T>(IEnumerable<T>): LinkedList<T> - Converts an IEnumerable<T>collection to a LinkedList.ToListAsync<T>(IEnumerable<T>): Task<List<T>>– Converts anIEnumerable<T>list to aList<T>.
Examples
Here are code examples for some of the methods in EnumerableExtensions.
var result = people.FastAny(p => p.Age.TotalDays > 365)
var result = await people.ToListAsync().ConfigureAwait(false);
New Methods
Here are more new methods that have been added to this version.
EnumberableExtensions
EnsureUnique<T>(): Ensures that the items in the collection are unique.
ListExtentions
AsSpan<T>(): Converts aList<T>to aSpan<T>.
MathExtensions
Add(): Adds two numbers.Subtract(): Subtracts two numbers.
StringExtensions
FromDeflateStringAsync(): Converts a deflate compressed string as an asynchronous operation.FromZLibStringAsync(): Converts a ZLib compressed string as an asynchronous operation.
Summary
I hope you will find these methods and more in Spargine useful for your projects. Benchmark results are published on GitHub and the links to them are in the ReadMe file. If you would like anything added, please do a pull request, or submit an issue. If you have any comments or suggestions, please make them below.
Happy coding geeks!
Discover more from dotNetTips.com
Subscribe to get the latest posts sent to your email.
