Choose action via console input - CSharp Language Basics

CSharp examples for Language Basics:Console

Description

Choose action via console input

Demo Code

using System;/*from www . j a  v a2  s .c o m*/
class ChooseAction
{
   public static void Main()
   {
      string choice;
      Console.Write("Enter either A, B or C: ");
      choice = Console.ReadLine();
      if(choice == "A")
         Console.WriteLine("You entered an A");
      else if (choice == "B")
         Console.WriteLine("You entered a B");
      else
         Console.WriteLine("You entered a C");      //unsound
   }
}

Result


Related Tutorials