Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

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);
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #async #method #parameter
ADD COMMENT
Topic
Name
7+5 =