CSharpEssentials.Any
3.0.4
dotnet add package CSharpEssentials.Any --version 3.0.4
NuGet\Install-Package CSharpEssentials.Any -Version 3.0.4
<PackageReference Include="CSharpEssentials.Any" Version="3.0.4" />
<PackageVersion Include="CSharpEssentials.Any" Version="3.0.4" />
<PackageReference Include="CSharpEssentials.Any" />
paket add CSharpEssentials.Any --version 3.0.4
#r "nuget: CSharpEssentials.Any, 3.0.4"
#:package CSharpEssentials.Any@3.0.4
#addin nuget:?package=CSharpEssentials.Any&version=3.0.4
#tool nuget:?package=CSharpEssentials.Any&version=3.0.4
CSharpEssentials.Any
Discriminated Unions (Sum Types) for .NET. A type-safe way to represent a value that can be one of several fixed types.
Features
- Unions of 2–8 types —
Any<T0, T1>throughAny<T0, ..., T7>. - Implicit Conversions — Assign values directly to the union type.
- Pattern Matching —
SwitchandMatchfor exhaustive handling. - Type Helpers —
Is<T>,As<T>,TryAs<T>,Deconstruct,ToTuple. - JSON Support — Built-in serialization.
Installation
dotnet add package CSharpEssentials.Any
Usage
Creating Unions
using CSharpEssentials.Any;
Any<string, int> ParseInput(string input)
{
if (int.TryParse(input, out int n))
return n; // implicit to Any<string, int>
return input;
}
Pattern Matching
Any<string, int> result = ParseInput("123");
string output = result.Match(
first: str => $"String: {str}",
second: num => $"Number: {num}");
result.Switch(
first: str => Console.WriteLine("It's a string"),
second: num => Console.WriteLine("It's a number"));
Type Checking
if (result.IsSecond)
{
int val = result.GetSecond();
}
// Generic helpers
bool isInt = result.Is<int, string, int>();
int? asInt = result.As<int, string, int>();
bool found = result.TryAs<int, string, int>(out int value);
Multiple Types
Any<string, int, Exception> response = GetData(5);
response.Switch(
first: s => Console.WriteLine($"Success: {s}"),
second: i => Console.WriteLine($"NotFound: {i}"),
third: e => Console.WriteLine($"Error: {e.Message}"));
| 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 was computed. 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 is compatible. 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. net11.0 is compatible. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | 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.1
- CSharpEssentials.Core (>= 3.0.4)
- CSharpEssentials.Json (>= 3.0.4)
- System.Text.Json (>= 9.0.0)
-
net10.0
- CSharpEssentials.Core (>= 3.0.4)
- CSharpEssentials.Json (>= 3.0.4)
-
net11.0
- CSharpEssentials.Core (>= 3.0.4)
- CSharpEssentials.Json (>= 3.0.4)
-
net9.0
- CSharpEssentials.Core (>= 3.0.4)
- CSharpEssentials.Json (>= 3.0.4)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on CSharpEssentials.Any:
| Package | Downloads |
|---|---|
|
CSharpEssentials
A comprehensive C# library enhancing functional programming capabilities with type-safe monads (Maybe, Result), discriminated unions (Any), and robust error handling. Features include: domain-driven design support, enhanced Entity Framework integration, testable time management, JSON utilities, and LINQ extensions. Built for modern C# development with focus on maintainability, testability, and functional programming principles. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.4 | 0 | 5/6/2026 |
| 3.0.3 | 3 | 5/5/2026 |
| 3.0.2 | 79 | 5/5/2026 |
| 3.0.1 | 87 | 5/3/2026 |
| 3.0.0 | 89 | 5/3/2026 |
| 2.1.0 | 271 | 11/26/2025 |
| 2.0.9 | 233 | 9/30/2025 |
| 2.0.8 | 228 | 9/29/2025 |
| 2.0.7 | 215 | 9/29/2025 |
| 2.0.6 | 213 | 9/29/2025 |
| 2.0.5 | 224 | 9/29/2025 |
| 2.0.4 | 206 | 9/28/2025 |
| 2.0.3 | 218 | 9/28/2025 |
| 2.0.2 | 227 | 9/28/2025 |
| 2.0.1 | 226 | 9/28/2025 |
| 2.0.0 | 223 | 9/28/2025 |