Struct Result<T>
- Namespace
- LfrlAnvil
- Assembly
- LfrlAnvil.Core.dll
Represents a result of an operation.
public readonly struct Result<T>
Type Parameters
TType of an optional value.
- Inherited Members
- Extension Methods
Properties
Exception
Optional Exception associated with this result.
public Exception? Exception { get; }
Property Value
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
GetValueOrThrow()
[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
valueResult<T>Object to convert.
Returns
implicit operator Result<T>(Exception)
Converts provided exception to Result<T>.
[Pure]
public static implicit operator Result<T>(Exception exception)
Parameters
exceptionExceptionException from which to create an error result.
Returns
implicit operator Result<T>(T?)
Converts provided value to Result<T>.
[Pure]
public static implicit operator Result<T>(T? value)
Parameters
valueTValue associated with the result.