Table of Contents

InvokeOrDefault Method

Definition

Namespace
Cuemon
Assemblies
Cuemon.Kernel.dll
Source
src/Cuemon.Kernel/Patterns.cs

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

method Func<TResult>

The function delegate that will return an instance of TResult.

fallbackResult TResult

The value to return when the specified method throws an exception. Default is default of TResult.

Returns

TResult

An object of TResult when the specified method can be invoked without an exception; otherwise fallbackResult is returned.

Type Parameters

TResult

The type of the return value of the method.