Reputation: 3
I am using async Task method. Is there any way to return false from this method. If not how can I handle this scenario?
public static async Task Share(MemoryStream streamToEmail)
{
if(streamToEmail.Length < 10000000)
{
await SendEmails();
}
else
{
//return false;
}
}
Upvotes: 0
Views: 304
Reputation: 840
Not unless you are planning to also return some boolean in the if-branch. If you do though, you could do it like this:
public static async Task<bool> Share(MemoryStream streamToEmail)
{
if(streamToEmail.Length < 10000000)
{
await SendEmails();
return true;
}
else
{
return false;
}
}
Upvotes: 2