Rop.Results9 1.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Rop.Results9 --version 1.2.0                
NuGet\Install-Package Rop.Results9 -Version 1.2.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Rop.Results9" Version="1.2.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Rop.Results9 --version 1.2.0                
#r "nuget: Rop.Results9, 1.2.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Rop.Results9 as a Cake Addin
#addin nuget:?package=Rop.Results9&version=1.2.0

// Install Rop.Results9 as a Cake Tool
#tool nuget:?package=Rop.Results9&version=1.2.0                

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 Compatible and additional computed target framework versions.
.NET net9.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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.

Version Downloads Last updated
1.2.3 86 10/30/2024
1.2.2 97 10/7/2024
1.2.1 102 10/7/2024
1.2.0 89 10/7/2024