CSharp examples for Language Basics:Console
Read string from console and check its value
class Hello//from ww w . j a v a2s .c o m { public static void Main() { string answer; System.Console.WriteLine("Do you want me to write the two words?"); System.Console.WriteLine("Type y for yes; n for no. Then <enter>"); answer = System.Console.ReadLine(); if (answer == "y") System.Console.WriteLine("Hello World!"); System.Console.WriteLine("Bye Bye!"); } }