Monday, March 30, 2015

Does C# support try-catch-finally blocks?

Question:Does C# support try-catch-finally blocks??

Answer: </P><P align=justify>Yes. Try-catch-finally blocks are supported by the C# compiler. </P><P align=justify>Here&#39;s an example of a try-catch-finally block: using System;</P><P align=justify>public class TryTest</P><P align=justify>{</P><P align=justify>static void Main()</P><P align=justify>{</P><P align=justify>try</P><P align=justify>{</P><P align=justify>Console.WriteLine("In Try block");</P><P align=justify>throw new ArgumentException();</P><P align=justify>}</P><P align=justify>catch(ArgumentException n1)</P><P align=justify>{</P><P align=justify>Console.WriteLine("Catch Block");</P><P align=justify>}</P><P align=justify>finally</P><P align=justify>{</P><P align=justify>Console.WriteLine("Finally Block");</P><P align=justify>}</P><P align=justify>}</P><P align=justify>}</P><P align=justify></P><P align=justify>Output: In Try Block</P><P align=justify>Catch Block</P><P align=justify>Finally Block

Tags:Interview Questions, Microsoft, C#,

Please submit your Interview Answer for the above Question via replying to this post. Thank you for visiting to our blog, Have a Good Day!.



Sponsor Advertisement



Hospital Management Software

Hotel Management System Software

Hotel Management System software is a web based system help to manage reservations, roomstays, bookings, guests, folios, invoices and billing etc. The software features include revenue management, booking calendar, guest relationship management, check-in & check-out, invoices and receipts etc...

No comments:

Post a Comment