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;
}
}
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;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.