Does C# support try-catch-finally blocks?

Yes. Try-catch-finally blocks are supported by the C# compiler.

Here's an example of a try-catch-finally block: using System;

public class TryTest

{

static void Main()

{

try

{

Console.WriteLine("In Try block");

throw new ArgumentException();

}

catch(ArgumentException n1)

{

Console.WriteLine("Catch Block");

}

finally

{

Console.WriteLine("Finally Block");

}

}

}

Output: In Try Block

Catch Block

Finally Block

Showing Answers 1 - 1 of 1 Answers

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions