Result.Simplified 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Result.Simplified --version 1.0.1
                    
NuGet\Install-Package Result.Simplified -Version 1.0.1
                    
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="Result.Simplified" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Result.Simplified" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Result.Simplified" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Result.Simplified --version 1.0.1
                    
#r "nuget: Result.Simplified, 1.0.1"
                    
#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.
#:package Result.Simplified@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Result.Simplified&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Result.Simplified&version=1.0.1
                    
Install as a Cake Tool

Result.Simplified

License

Result.Simplified enables dot net methods to return an indication of success or failure, for any method return type (including void). It shouldn't be used instead of exceptions, but rather enable a method to return a failure indication in non-exceptional circumstances.

Use Result to enable void methods to return an indication of success or failure, and Result<T> to enable non-void methods to do the same.

Both Result and Result<T> overloads the & and | operators as well as the true and false operators, meaning you can easily combine results in a short-circute manner for easy validations.

Usage example:

Return a Result from a method:

Result DoSomething()
{
    // some code...
    return condition
        ? Result.Success()
        : Result.Fail("Something went wrong...");
}

Return a Result<T> from a method:

Result<int> DoSomethingAndReturnAnInt()
{
    // some code...
    return condition
        ? Result<int>.Success(5)
        : Result<int>.Fail("Something went wrong...");
}

Consume a method that returns a Result

void DoIfMethodSucceeded()
{
    var result = DoSomething();
    if(!result.IsSuccess)
    {   
        // Something went wrong, do something with result.ErrorDescription 
        // log or show the user or whatever
        return;
    }
        // Everything is fine, you can go on with your code
    }

Consume a method that returns a Result<T>

bool DoIfMethodSucceeded()
{
    var result = DoSomethingAndReturnAnInt();
    if(!result.IsSuccess)
    {   
        // Something went wrong, do something with result.ErrorDescription 
        // log or show the user or whateverlog or show the user or whatever
        return false;
    }
        var intValue = result.Value;
        // Everything is fine, you can go on with your code
    }

Note: Since Result and Result<T> overloads the true and false operators, you don't techinally have to use the IsSeuccess property to check if the result is a success or not, but I do recommend it for readability.

void DoIfMethodSucceeded()
{
    var result = DoSomething();
    if(!result)
    {   
        // Something went wrong, do something with result.ErrorDescription 
        // log or show the user or whatever
        return;
    }
        // Everything is fine, you can go on with your code
    }

Since Result and Result<T> overloads the & and | operators as well, you can combine multiple results in a short-circuit manner.

Result FailFast()
{
    var result = DoSomething() // returns a result instance
        && DoSomethingElse() // returns nother result instance
        && DoAnotherThing() // returns nother result instance;

    // result is the first failed result, or the last one if all succeeded.

    return result;
}

Result FailSlow()
{

    var result = DoSomething() // returns a result instance
        || DoSomethingElse() // returns nother result instance
        || DoAnotherThing() // returns nother result instance;
    
    // result is the last failed result, or the first one if all succeeded.

    return result;    
}

And a validation usage example:

Result<SomeObject> Validate(SomeObject someObject)
{
    
    return Validate("someObject is null.", d => d is object) 
        && Validate("someObject has no SomeProperty.", d => d.SomeProperty is object) 
        && Validate("SomeProperty is invalid.", d => d.SomeProperty.IsValid) 
        && Validate("SomeCollection is empty.", d => (d.SomeCollection?.Count ?? 0) > 0);

    Result<SomeObject> Validate(string errorMessage, Predicate<SomeObject> predicate)
    {
        var isValid = predicate(someObject);
        if (!isValid)
        {
            // Log non-exceptional error here...
        }
        return isValid 
            ? Result<SomeObject>.Success(rbMatch) 
            : Result<SomeObject>.Fail(errorMessage);
    }
}
Product 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 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. 
.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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.
  • 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.

Version Downloads Last Updated
3.0.0 159 2/6/2026
2.4.0 272 10/27/2025
2.3.0 241 8/20/2025
2.2.0 209 7/30/2025
2.1.0 257 4/24/2025
2.0.0 259 4/21/2025
1.1.0 213 4/18/2025
1.0.1 292 4/17/2025
1.0.0 237 4/13/2025

Updated Readme