InvokeOrDefault Method
Definition
InvokeOrDefault<TResult>(Func<TResult>, TResult)
Returns an object of TResult, or a default value if the specified method throws an exception.
public static TResult InvokeOrDefault<TResult>(Func<TResult> method, TResult fallbackResult = default)
Parameters
methodFunc<TResult>The function delegate that will return an instance of
TResult.fallbackResultTResultThe value to return when the specified
methodthrows an exception. Default isdefaultofTResult.
Returns
- TResult
An object of
TResultwhen the specifiedmethodcan be invoked without an exception; otherwisefallbackResultis returned.
Type Parameters
TResultThe type of the return value of the
method.