6
Reply

Can we use await in catch and finally blocks?

Dennis Thomas

Dennis Thomas

7y
5.6k
5
Reply

    Yes, we can use it, from C# 6.0 onward. C# 6 was introduced with Visual Studio 2015. It supports using await in catch and finally blocks.

    C# 6.0 came with another new feature along with Visual Studio 2015 and .NET 4.6. Now you will be able to write await operations in catch {} and finally {} blocks too.

    yes

    try { throw new Exception(); } catch { await Task.Delay(1000); //using await in catch block } finally { await Task.Delay(1000); //using await in finally block }

    Yes, we can use await in catch and finally blocks in c# 6.0 onwards.

    yes