Table of Contents

Struct Result<T>

Namespace
Executables
Assembly
executables.dll

Represents either a successful value or a failure exception.

public readonly struct Result<T> : IEquatable<Result<T>>

Type Parameters

T

Successful value type.

Implements
Inherited Members

Properties

Exception

Gets the failure exception, or null for successful results.

public Exception Exception { get; }

Property Value

Exception

IsFailure

Gets a value indicating whether the result represents failure.

public bool IsFailure { get; }

Property Value

bool

IsSuccess

Gets a value indicating whether the result represents success.

public bool IsSuccess { get; }

Property Value

bool

Value

Gets the successful value or throws when result is a failure.

public T Value { get; }

Property Value

T

Exceptions

InvalidOperationException

Throws when result is a failure.

Methods

Equals(Result<T>)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(Result<T> other)

Parameters

other Result<T>

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object)

Indicates whether this instance and a specified object are equal.

public override bool Equals(object obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

FromException(Exception)

Creates a failed result from exception.

public static Result<T> FromException(Exception exception)

Parameters

exception Exception

Failure exception.

Returns

Result<T>

Failed result instance.

Exceptions

ArgumentNullException

Throws when exception is null.

FromResult(T)

Creates a successful result from value.

public static Result<T> FromResult(T value)

Parameters

value T

Successful value.

Returns

Result<T>

Successful result instance.

GetHashCode()

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

ThrowIfFailure()

Throws stored exception when result is a failure.

public void ThrowIfFailure()

ToString()

Returns textual representation of the value or failure exception.

public override string ToString()

Returns

string

String representation of current result.

TryGetValue(out T)

Attempts to get successful value.

public bool TryGetValue(out T value)

Parameters

value T

When this method returns, contains the successful value or default value on failure.

Returns

bool

true for success; otherwise false.

Operators

operator ==(Result<T>, Result<T>)

public static bool operator ==(Result<T> left, Result<T> right)

Parameters

left Result<T>
right Result<T>

Returns

bool

operator !=(Result<T>, Result<T>)

public static bool operator !=(Result<T> left, Result<T> right)

Parameters

left Result<T>
right Result<T>

Returns

bool