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. Console Menu Application

Console Menu Application

Scheduled Pinned Locked Moved C#
help
4 Posts 2 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.
  • I Offline
    I Offline
    invalidsyntax1010
    wrote on last edited by
    #1

    Hello I am messing around making things that tell the time zone and other things to learn c # I was wandering when you see a console app with numbers eg 1. get time zone 2. get date and time 3 etc how do you do such a menu Thanks for the help Mark:laugh: Noobster

    L 1 Reply Last reply
    0
    • I invalidsyntax1010

      Hello I am messing around making things that tell the time zone and other things to learn c # I was wandering when you see a console app with numbers eg 1. get time zone 2. get date and time 3 etc how do you do such a menu Thanks for the help Mark:laugh: Noobster

      L Offline
      L Offline
      Lutoslaw
      wrote on last edited by
      #2

      static void Main(string[] args)
      {
      Console.WriteLine("Input number and press ENTER to choose option:");
      bool loop = true;
      while (loop) {
      Console.WriteLine("0 - Exit");
      Console.WriteLine("1 - Get Time Zone");
      Console.WriteLine("2 - Get Date and Time");
      // etc.
      switch (Console.ReadLine()) {
      case "0":
      loop = false;
      break;
      case "1":
      Console.WriteLine(System.TimeZone.CurrentTimeZone.StandardName);
      break;
      case "2":
      Console.WriteLine(DateTime.Now.ToLongDateString() + ", " + DateTime.Now.ToLongTimeString());
      break;
      // etc.
      default:
      break;
      }
      }
      }

      Hope this'll help :)

      Greetings - Gajatko

      I 1 Reply Last reply
      0
      • L Lutoslaw

        static void Main(string[] args)
        {
        Console.WriteLine("Input number and press ENTER to choose option:");
        bool loop = true;
        while (loop) {
        Console.WriteLine("0 - Exit");
        Console.WriteLine("1 - Get Time Zone");
        Console.WriteLine("2 - Get Date and Time");
        // etc.
        switch (Console.ReadLine()) {
        case "0":
        loop = false;
        break;
        case "1":
        Console.WriteLine(System.TimeZone.CurrentTimeZone.StandardName);
        break;
        case "2":
        Console.WriteLine(DateTime.Now.ToLongDateString() + ", " + DateTime.Now.ToLongTimeString());
        break;
        // etc.
        default:
        break;
        }
        }
        }

        Hope this'll help :)

        Greetings - Gajatko

        I Offline
        I Offline
        invalidsyntax1010
        wrote on last edited by
        #3

        wow i was thinking of making variables for each option then having a if statement haha i guess switch is better for more options.. trying to grasp the bool loop = true; it keeps asking me once i pick a answer i guess instead of writing a bunch of Console.WriteLine(); cool Good stuff my brain is frying today lol :-D

        L 1 Reply Last reply
        0
        • I invalidsyntax1010

          wow i was thinking of making variables for each option then having a if statement haha i guess switch is better for more options.. trying to grasp the bool loop = true; it keeps asking me once i pick a answer i guess instead of writing a bunch of Console.WriteLine(); cool Good stuff my brain is frying today lol :-D

          L Offline
          L Offline
          Lutoslaw
          wrote on last edited by
          #4

          I use "loop" variable instead of just "true" to avoid goto statement. In the case "0" a statement "double break" whould do the trick, but there isn't such thing. So set the variable to false and the next loop will not evaluate.

          Greetings - Gajatko

          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