BetterOutcome 1.1.1
dotnet add package BetterOutcome --version 1.1.1
NuGet\Install-Package BetterOutcome -Version 1.1.1
<PackageReference Include="BetterOutcome" Version="1.1.1" />
<PackageVersion Include="BetterOutcome" Version="1.1.1" />
<PackageReference Include="BetterOutcome" />
paket add BetterOutcome --version 1.1.1
#r "nuget: BetterOutcome, 1.1.1"
#:package BetterOutcome@1.1.1
#addin nuget:?package=BetterOutcome&version=1.1.1
#tool nuget:?package=BetterOutcome&version=1.1.1
BetterOutcome
The word "outcome" is a noun that means the result or effect of an action, situation, or event. It can also refer to a conclusion reached through logical thinking.
The BetterOutcome library aims to provide a simple and object-oriented Option implementation for C# (slightly inspired by Rust's implementation).
Quickstart
First of all, install the package.
dotnet add package BetterOutcome
In this simple example, Option is used to wrap the result of a Customer query endpoint and return Ok or NotFound accordingly.
[HttpGet("{id:int}")]
public IActionResult Get(int id)
{
var result = GetCustomer(id);
return result switch
{
Some<Customer> customer => Ok(customer.Value),
_ => NotFound() // the operator _ can match the None<Customer> case
};
}
private static Option<Customer> GetCustomer(int id)
{
return Option<Customer>.CreateFromValue(_customers.GetValueOrDefault(id));
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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 was computed. 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. |
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.