Table of Contents

Struct Result<T>

Namespace
LfrlAnvil
Assembly
LfrlAnvil.Core.dll

Represents a result of an operation.

public readonly struct Result<T>

Type Parameters

T

Type of an optional value.

Inherited Members
Extension Methods

Properties

Exception

Optional Exception associated with this result.

public Exception? Exception { get; }

Property Value

Exception

Value

Optional value associated with this result.

public T? Value { get; }

Property Value

T

Methods

Deconstruct(out T?, out Exception?)

Deconstruct this Result<T> instance.

public void Deconstruct(out T? value, out Exception? exception)

Parameters

value T

out parameter that returns Value.

exception Exception

out parameter that returns Exception.

GetValueOrThrow()

Returns Value if Exception is null, otherwise rethrows the Exception.

[Pure]
public T? GetValueOrThrow()

Returns

T

Underlying Value.

ThrowIfError()

Rethrows the Exception, if it isn't null, otherwise does nothing.

public void ThrowIfError()

ToString()

Returns the fully qualified type name of this instance.

[Pure]
public override string ToString()

Returns

string

The fully qualified type name.

Operators

implicit operator Result(Result<T>)

Converts provided value to Result.

[Pure]
public static implicit operator Result(Result<T> value)

Parameters

value Result<T>

Object to convert.

Returns

Result

New Result instance.

implicit operator Result<T>(Exception)

Converts provided exception to Result<T>.

[Pure]
public static implicit operator Result<T>(Exception exception)

Parameters

exception Exception

Exception from which to create an error result.

Returns

Result<T>

New Result<T> instance.

implicit operator Result<T>(T?)

Converts provided value to Result<T>.

[Pure]
public static implicit operator Result<T>(T? value)

Parameters

value T

Value associated with the result.

Returns

Result<T>

New Result<T> instance.