Class Result<TError>

Namespace
Cratis.Monads
Assembly
Cratis.Fundamentals.dll

Represents the result of trying an execution that returns success or a specific error.

public class Result<TError> : OneOfBase<None, TError>, IOneOf

Type Parameters

TError

The type of the error.

Inheritance
OneOfBase<None, TError>
Result<TError>
Implements
IOneOf
Inherited Members
OneOfBase<None, TError>.TryPickT0(out None, out TError)
OneOfBase<None, TError>.TryPickT1(out TError, out None)
OneOfBase<None, TError>.ToString()
OneOfBase<None, TError>.GetHashCode()
OneOfBase<None, TError>.Value
OneOfBase<None, TError>.Index
OneOfBase<None, TError>.IsT0
OneOfBase<None, TError>.IsT1
OneOfBase<None, TError>.AsT0
OneOfBase<None, TError>.AsT1
Extension Methods

Properties

IsSuccess

Gets a value indicating whether the execution was successful.

public bool IsSuccess { get; }

Property Value

bool

Methods

Failed(TError)

Creates a failed Result<TError>.

public static Result<TError> Failed(TError error)

Parameters

error TError

The error.

Returns

Result<TError>

The created Result<TError>.

Success()

Creates a successful Result<TError>.

public static Result<TError> Success()

Returns

Result<TError>

The created Result<TError>.

TryGetError(out TError?)

Try to get the error.

public bool TryGetError(out TError? error)

Parameters

error TError

The optional error.

Returns

bool

A boolean indicating whether the error was present.

Operators

explicit operator TError(Result<TError>)

public static explicit operator TError(Result<TError> obj)

Parameters

obj Result<TError>

Returns

TError

implicit operator Result<TError>(TError)

public static implicit operator Result<TError>(TError error)

Parameters

error TError

Returns

Result<TError>