How do I exit the program?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Amanda

    How do I exit the program?

    (1) What code should I put in case 'e':?
    (2) Should I still put default case?


    do
    {
    Console.Write(" Enter a selection from the following
    list:\n" +
    "a. Display ............... ....\n" +
    "b. Display ............... .....\n." +
    "c. Display ............... .\n.." +
    "e. Exit this program\n");


    ch = Char.Parse(Cons ole.ReadLine()) ;
    Console.WriteLi ne("");


    switch (ch)
    {

    case 'e':
    ????????

    } // end switch


    } while ( ch== etc.)

  • Forrest

    #2
    Re: How do I exit the program?


    Uzytkownik "Amanda" <amanda772008@y ahoo.comnapisal w wiadomosci
    news:1160373661 .147072.137680@ k70g2000cwa.goo glegroups.com.. .
    (1) What code should I put in case 'e':?
    (2) Should I still put default case?
    >
    >
    do
    {
    Console.Write(" Enter a selection from the following
    list:\n" +
    "a. Display ............... ....\n" +
    "b. Display ............... .....\n." +
    "c. Display ............... .\n.." +
    "e. Exit this program\n");
    >
    >
    ch = Char.Parse(Cons ole.ReadLine()) ;
    Console.WriteLi ne("");
    >
    >
    switch (ch)
    {
    >
    case 'e':
    ????????
    >
    } // end switch
    >
    >
    } while ( ch== etc.)
    >
    Try this one. Add reference System.Windows. Forms in to your project and then
    you can use Application.Exi t()

    Forrest


    Comment

    • Amanda

      #3
      Re: How do I exit the program?


      Forrest wrote:
      Uzytkownik "Amanda" <amanda772008@y ahoo.comnapisal w wiadomosci
      news:1160373661 .147072.137680@ k70g2000cwa.goo glegroups.com.. .
      (1) What code should I put in case 'e':?
      [..]
      >
      Try this one. Add reference System.Windows. Forms in to your project and then
      you can use Application.Exi t()
      This is Console application as required by sample exe file given.



      >
      Forrest

      Comment

      • Forrest

        #4
        Re: How do I exit the program?


        Uzytkownik "Amanda" <amanda772008@y ahoo.comnapisal w wiadomosci
        news:1160375910 .353930.256710@ k70g2000cwa.goo glegroups.com.. .
        >
        Forrest wrote:
        >Uzytkownik "Amanda" <amanda772008@y ahoo.comnapisal w wiadomosci
        >news:116037366 1.147072.137680 @k70g2000cwa.go oglegroups.com. ..
        (1) What code should I put in case 'e':?
        >[..]
        >
        >>
        >Try this one. Add reference System.Windows. Forms in to your project and
        >then
        >you can use Application.Exi t()
        >
        This is Console application as required by sample exe file given.
        >
        >
        >
        >
        >>
        >Forrest
        >
        Ok, maybe try this one
        Environment.Exi t(0);

        Forrest


        Comment

        • Jon Slaughter

          #5
          Re: How do I exit the program?


          "Amanda" <amanda772008@y ahoo.comwrote in message
          news:1160373661 .147072.137680@ k70g2000cwa.goo glegroups.com.. .
          (1) What code should I put in case 'e':?
          (2) Should I still put default case?
          >
          >
          do
          {
          Console.Write(" Enter a selection from the following
          list:\n" +
          "a. Display ............... ....\n" +
          "b. Display ............... .....\n." +
          "c. Display ............... .\n.." +
          "e. Exit this program\n");
          >
          >
          ch = Char.Parse(Cons ole.ReadLine()) ;
          Console.WriteLi ne("");
          >
          >
          switch (ch)
          {
          >
          case 'e':
          ????????
          >
          } // end switch
          >
          >
          } while ( ch== etc.)
          >
          Enviroment.Exit (int n);

          n is errorcode returned to os.


          Comment

          • Christof Nordiek

            #6
            Re: How do I exit the program?

            (1):
            return;

            or

            break;

            depending on the context of the loop.

            or {} and then in the contidition: ch != 'e';

            (2):
            Maybe prompt some error message;
            what does the sample exe do?

            "Amanda" <amanda772008@y ahoo.comschrieb im Newsbeitrag
            news:1160373661 .147072.137680@ k70g2000cwa.goo glegroups.com.. .
            (1) What code should I put in case 'e':?
            (2) Should I still put default case?
            >
            >
            do
            {
            Console.Write(" Enter a selection from the following
            list:\n" +
            "a. Display ............... ....\n" +
            "b. Display ............... .....\n." +
            "c. Display ............... .\n.." +
            "e. Exit this program\n");
            >
            >
            ch = Char.Parse(Cons ole.ReadLine()) ;
            Console.WriteLi ne("");
            >
            >
            switch (ch)
            {
            >
            case 'e':
            ????????
            >
            } // end switch
            >
            >
            } while ( ch== etc.)
            >

            Comment

            • Amanda

              #7
              Re: How do I exit the program?


              Christof Nordiek wrote:
              (1):
              return;
              >
              or
              >
              break;
              >
              depending on the context of the loop.
              I tried break before my initial post - it didn't work - but return
              does. Thnaks.
              >
              or {} and then in the contidition: ch != 'e';
              >
              (2):
              Maybe prompt some error message;
              what does the sample exe do?
              It says "Press any key to continue..."


              >
              "Amanda" <amanda772008@y ahoo.comschrieb im Newsbeitrag
              news:1160373661 .147072.137680@ k70g2000cwa.goo glegroups.com.. .
              (1) What code should I put in case 'e':?
              (2) Should I still put default case?


              do
              {
              Console.Write(" Enter a selection from the following
              list:\n" +
              "a. Display ............... ....\n" +
              "b. Display ............... .....\n." +
              "c. Display ............... .\n.." +
              "e. Exit this program\n");


              ch = Char.Parse(Cons ole.ReadLine()) ;
              Console.WriteLi ne("");


              switch (ch)
              {

              case 'e':
              ????????

              } // end switch


              } while ( ch== etc.)

              Comment

              Working...