Answers for "async method out parameter c#"

C#
0

async method out parameter c#

// NOTE: You can't have async methods with ref or out parameters.

public async Task Method1()
{
    var result = await TestAsync();
    int code = result.successCode;
    bool error = tuple.error;
}

// A workaround for this is to just return a tuple 
public async Task<(int successCode, bool error)> TestAsync()
{
    //...
    return (1, true);
}
Posted by: Guest on September-29-2021

C# Answers by Framework

Browse Popular Code Answers by Language