Dev.Util.Collections
1.2.2
See the version list below for details.
dotnet add package Dev.Util.Collections --version 1.2.2
NuGet\Install-Package Dev.Util.Collections -Version 1.2.2
<PackageReference Include="Dev.Util.Collections" Version="1.2.2" />
<PackageVersion Include="Dev.Util.Collections" Version="1.2.2" />
<PackageReference Include="Dev.Util.Collections" />
paket add Dev.Util.Collections --version 1.2.2
#r "nuget: Dev.Util.Collections, 1.2.2"
#:package Dev.Util.Collections@1.2.2
#addin nuget:?package=Dev.Util.Collections&version=1.2.2
#tool nuget:?package=Dev.Util.Collections&version=1.2.2
Dev.Util.Collections
High-performance collection and dictionary manipulation utilities for the Dev.Util ecosystem. Optimized for large datasets and complex data structures.
📦 Installation
dotnet add package Dev.Util.Collections
✨ Features
- 📖 Safe Dictionary Access: Avoid
KeyNotFoundExceptionwith smart defaults. - 📄 Pagination: Convert any
IEnumerableinto a metadata-richPagedList<T>. - 📦 Batching/Chunking: Split large collections for efficient batch processing.
- 🌳 Tree Traversal: Recursively flatten nested structures with a single line.
- 🎲 Randomization: Shuffle lists or pick random elements with ease.
- ⛓️ Fluent Lists: Chainable modification methods (
AddRangeFluent, etc).
🛠 Usage Examples
1. Paginated Results (API Ready)
Perfect for returning data to front-end grids with metadata.
using Dev.Util.Collections;
var rawData = dbContext.Users.AsEnumerable();
// Returns PagedList<T> with TotalPages, TotalCount, HasNextPage etc.
var paged = rawData.ToPagedList(pageIndex: 1, pageSize: 20);
Console.WriteLine($"Showing page {paged.PageIndex} of {paged.TotalPages}");
2. High-Capacity Batching
Processes large collections in smaller, manageable chunks (ideal for DB imports).
using Dev.Util.Collections;
var largeList = Enumerable.Range(1, 10000);
foreach (var batch in largeList.Batch(100))
{
// batch is IEnumerable<int> with 100 items
await SaveToDatabase(batch);
}
3. Safe Dictionary Interaction
Eliminate repetitive ContainsKey checks.
using Dev.Util.Collections;
var settings = new Dictionary<string, string> { ["Theme"] = "Dark" };
// Safe Get
string theme = settings.GetValueOrDefault("Theme", "Light"); // "Dark"
string mode = settings.GetValueOrDefault("Mode", "Simple"); // "Simple"
// Fluent Add if not exists
settings.AddIfNotNull("Language", "EN");
4. Recursive Traversal
Flatten complex hierarchies like File Systems or UI TreeViews.
using Dev.Util.Collections;
var allNodes = rootCategory.Traverse(c => c.SubCategories);
foreach(var node in allNodes) {
// Process every nested category flatly
}
5. Randomization & Selection
Utility methods for UI or testing.
using Dev.Util.Collections;
var winners = users.PickRandom(3); // Pick 3 random users
users.Shuffle(); // Randomize the entire list in-place
Dev.Util.Collections methods are designed to be LINQ-interoperable and performant for memory management.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Dev.Util.Core (>= 1.2.2)
-
net8.0
- Dev.Util.Core (>= 1.2.2)
-
net9.0
- Dev.Util.Core (>= 1.2.2)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Dev.Util.Collections:
| Package | Downloads |
|---|---|
|
Dev.Util
The complete Dev.Util ecosystem for .NET. One package to rule them all. Provides access to Core, Collections, IO, Security, Web, Reflection, Tasks, and Json modules. |
GitHub repositories
This package is not used by any popular GitHub repositories.