Rop.Results9
1.2.1
See the version list below for details.
dotnet add package Rop.Results9 --version 1.2.1
NuGet\Install-Package Rop.Results9 -Version 1.2.1
<PackageReference Include="Rop.Results9" Version="1.2.1" />
paket add Rop.Results9 --version 1.2.1
#r "nuget: Rop.Results9, 1.2.1"
// Install Rop.Results9 as a Cake Addin #addin nuget:?package=Rop.Results9&version=1.2.1 // Install Rop.Results9 as a Cake Tool #tool nuget:?package=Rop.Results9&version=1.2.1
Rop.Results9
Rop.Result
is a C# library that provides a way to handle errors without exceptions.
Instead of throwing an exception, functions return a Result
object that can be either a Success
or a Failed
state.
Installation
To install the library, you can use the NuGet package manager. In the Visual Studio terminal, run the following command:
Install-Package Rop.Results9
Usage
To use the library, you need to import the Rop.Result9
namespace:
using Rop.Result9;
Then you can create Result
objects using implicit conversions:
public Result<int> Divide1(int dividend, int divisor)
{
if (divisor == 0)
{
return Error.Fail("Cannot divide by zero.");
}
else
{
return dividend / divisor;
}
}
You can also use the Result
object in a fluent way:
public VoidResult ShowDivide(int divident,int divisor)
{
var result = Divide1(divident, divisor);
return result.Map(
v => Console.WriteLine($"The result is {result.Value}"),
e => Console.WriteLine($"Error: {result.Error!.Value}")
);
}
public VoidResult ShowDivide2(int divident,int divisor)
{
var result = Divide1(divident, divisor);
if (result.IsFailed)
return result;
Console.WriteLine($"The result is {result.Value!}");
return VoidResult.Ok;
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. |
-
net9.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Rop.Results9:
Package | Downloads |
---|---|
Rop.Winforms9.Helper
Helper classes for Winforms |
|
Rop.Winforms9.Basic
Basic Forms classes for Winforms |
GitHub repositories
This package is not used by any popular GitHub repositories.