Exception??
-
Exception Sample : static void Main(string[] args) { try{ Console.WriteLine("Level 1"); try { Console.WriteLine("Level 2"); goto exit; } finally { Console.WriteLine("Level 2 Finished"); } } finally { Console.WriteLine("Level 1 Finished"); } exit: ; } What is the wrong in this code sample above?
If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "
-
Exception Sample : static void Main(string[] args) { try{ Console.WriteLine("Level 1"); try { Console.WriteLine("Level 2"); goto exit; } finally { Console.WriteLine("Level 2 Finished"); } } finally { Console.WriteLine("Level 1 Finished"); } exit: ; } What is the wrong in this code sample above?
If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "
-
hi kulakarni, thanks for the response. actually today i took one pre assessment test in C#. they asked this question. they gave me 5 options: What is the console output for the code sample above? Choice 1 Level 1 Level 2 Level 2 Finished Level 1 Finished Choice 2 Level 1 Level 2 Level 1 Finished Choice 3 Level 1 Level 2 Choice 4 Level 1 Level 2 Level 1 Finished Level 2 Finished Choice 5 Level 1 Level 2 Level 2 Finished which one is the correct out put? Thanks, Rahi
If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "
-
hi kulakarni, thanks for the response. actually today i took one pre assessment test in C#. they asked this question. they gave me 5 options: What is the console output for the code sample above? Choice 1 Level 1 Level 2 Level 2 Finished Level 1 Finished Choice 2 Level 1 Level 2 Level 1 Finished Choice 3 Level 1 Level 2 Choice 4 Level 1 Level 2 Level 1 Finished Level 2 Finished Choice 5 Level 1 Level 2 Level 2 Finished which one is the correct out put? Thanks, Rahi
If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "
It is obvious choice1. Because of the rule that finally block is always executed inspite of any excpetion is occured or not. In this case, inner most try and finally is executed first and then the outer one. :)
Jayant D. Kulkarni Brainbench Certified Software Engineer in C#, ASP.NET, .NET Framework and ADO.NET
-
It is obvious choice1. Because of the rule that finally block is always executed inspite of any excpetion is occured or not. In this case, inner most try and finally is executed first and then the outer one. :)
Jayant D. Kulkarni Brainbench Certified Software Engineer in C#, ASP.NET, .NET Framework and ADO.NET
oho....thanks Kulakarni. i know this but when i saw the question, i didn't understand the question first of all........now i came to know the correct answer! Thanks, Rahi
If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "
-
Exception Sample : static void Main(string[] args) { try{ Console.WriteLine("Level 1"); try { Console.WriteLine("Level 2"); goto exit; } finally { Console.WriteLine("Level 2 Finished"); } } finally { Console.WriteLine("Level 1 Finished"); } exit: ; } What is the wrong in this code sample above?
If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "