SumType<T1,T2>.Match<TResult> Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Runs a delegate corresponding to which type is contained inside this instance.
public TResult Match<TResult> (Func<T1,TResult> firstMatch, Func<T2,TResult> secondMatch, Func<TResult> defaultMatch = default);
public TResult Match<TResult> (Func<T1,TResult> firstMatch, Func<T2,TResult> secondMatch, Func<TResult>? defaultMatch = default);
member this.Match : Func<'T1, 'Result> * Func<'T2, 'Result> * Func<'Result> -> 'Result
Public Function Match(Of TResult) (firstMatch As Func(Of T1, TResult), secondMatch As Func(Of T2, TResult), Optional defaultMatch As Func(Of TResult) = Nothing) As TResult
Type Parameters
- TResult
The type that all the delegates will return.
Parameters
- firstMatch
- Func<T1,TResult>
Delegate to handle the case where this instance contains a T1
.
- secondMatch
- Func<T2,TResult>
Delegate to handle the case where this instance contains a T2
.
- defaultMatch
- Func<TResult>
Delegate to handle the case where this instance is uninhabited. If this delegate isn't provided the default
TResult
will be returned instead.
Returns
The TResult
instance created by the delegate corresponding to the current type stored in this instance.