I want to... Return the result of a successful operation - sameera/Codoxide.Outcome GitHub Wiki
A function that completes successfully returns a "successful outcome" which is indicated by a true
Outcome<T>.IsSuccessful
property. The result of a successful operation is held in a Result
property of the Outcome<T>
.
Outcome
type can implicitly cast from any type. Therefore, in most cases simply declaring your function to return an Outcome
should be sufficient.
e.g.
public Outcome<int> Add(int a, int b)
{
return a + b;
}
Invoking Add(10, 5) would result in an
Outcome` that has the following properties:
IsSuccessful = true
Result = 15
Failure = Null