Table of Contents

Delegate TesterFunc<TResult, TSuccess>

Namespace
Cuemon
Assembly
Cuemon.Kernel.dll

Encapsulates a method and returns a value that indicates success of the type specified by the TSuccess parameter and returns a out result value of the type specified by the TResult parameter.

public delegate TSuccess TesterFunc<TResult, out TSuccess>(out TResult result)

Parameters

result TResult

The result of the method that this function delegate encapsulates.

Returns

TSuccess

The return value that indicates success of the method that this function delegate encapsulates.

Type Parameters

TResult

The type of the out result value of the method that this function delegate encapsulates.

TSuccess

The type of the return value that indicates success of the method that this function delegate encapsulates.

Examples

The following example demonstrates the shared workflow for the family: call the delegate, capture the out value, and branch on the success result.

using System;
using Cuemon;

namespace MyApp.Examples;

public static class TesterFuncExample
{
    public static void Demonstrate()
    {
        TesterFunc<int, bool> tryReadPort = (out int port) =>
        {
            var configuredPort = "8080";
            return int.TryParse(configuredPort, out port);
        };

        var success = tryReadPort(out var port);

        Console.WriteLine(success);
        Console.WriteLine(port);
    }
}