📜  async方法out参数c#代码示例

📅  最后修改于: 2022-03-11 14:49:20.710000             🧑  作者: Mango

代码示例1
// 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);
}