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