Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Exception??

Exception??

Scheduled Pinned Locked Moved C#
question
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rahithi
    wrote on last edited by
    #1

    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... "

    J E 2 Replies Last reply
    0
    • R Rahithi

      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... "

      J Offline
      J Offline
      jdkulkarni
      wrote on last edited by
      #2

      Are you asking @ sytanx or what.. It will compile successfully.

      Jayant D. Kulkarni Brainbench Certified Software Engineer in C#, ASP.NET, .NET Framework and ADO.NET

      R 1 Reply Last reply
      0
      • J jdkulkarni

        Are you asking @ sytanx or what.. It will compile successfully.

        Jayant D. Kulkarni Brainbench Certified Software Engineer in C#, ASP.NET, .NET Framework and ADO.NET

        R Offline
        R Offline
        Rahithi
        wrote on last edited by
        #3

        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... "

        J 1 Reply Last reply
        0
        • R Rahithi

          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... "

          J Offline
          J Offline
          jdkulkarni
          wrote on last edited by
          #4

          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

          R 1 Reply Last reply
          0
          • J jdkulkarni

            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

            R Offline
            R Offline
            Rahithi
            wrote on last edited by
            #5

            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... "

            1 Reply Last reply
            0
            • R Rahithi

              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... "

              E Offline
              E Offline
              ednrgc
              wrote on last edited by
              #6

              The problem is that you are using GOTOs :wtf: Get over that crutch quickly.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups