Skip to content

Instantly share code, notes, and snippets.

@SchreinerK
Created July 5, 2019 04:43
Show Gist options
  • Save SchreinerK/4897a352be6e59db340b40d4422747ed to your computer and use it in GitHub Desktop.
Save SchreinerK/4897a352be6e59db340b40d4422747ed to your computer and use it in GitHub Desktop.
Result<Value>
public struct Result<TValue>
{
internal Result(TValue value, bool success, object failureInfo)
{
Value = value;
Success = success;
FailureInfo = failureInfo;
}
public TValue Value { get; private set; }
public bool Success { get; private set; }
public bool Failed => !Success;
public object FailureInfo { get; private set; }
}
public static class Result
{
public static Result<TValue> Success<TValue>(TValue value) => new Result<TValue>(value, true, null);
public static Result<TValue> Failed<TValue>(object failureInfo) => new Result<TValue>(default(TValue), false, failureInfo);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment