I have method e.g.
public async Task<int> AddUser()
{
//some logic
await _externalClass.DoSomething();
//some logic
}
And I want to get value from method await _externalClass.DoSomething();
(return type is Task and return type cannot be changed by me)
To make code like that:
public async Task<int> AddUser()
{
//some logic
await _externalClass.DoSomething();
if(valueThatIWantToGetFromExternalMethod)
{
//some logic
}
//some logic
}
How can I make this value from external method (this should be bool)valueThatIWantToGetFromExternalMethod
?
I thought that I can use ref
or out
keyword, but we can't do this in async methods in C#. Can someone show me how to implement this kind of logic?