C# program to demonstrate the use of finally blocks
Program.cs
string s = null;
try
{
    Console.WriteLine("Length: " + s.Length);
}
catch (Exception e)
{
    Console.WriteLine("Exception caught");
}
finally
{
    Console.WriteLine("Finally block is always get executed");
}
Output
codeaft@codeaft:~/csharp$ dotnet run
Exception caught
Finally block is always get executed
codeaft@codeaft:~/csharp$ 
Comments and Reactions