CSharp examples for Language Basics:Console
Check the string read from console
using System;/*from ww w . j ava 2 s . c o m*/ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Program { static void Main(string[] args) { // Input Console.Write("Enter password: "); string enteredPassword = Console.ReadLine(); // Password check if (enteredPassword == "friend") { Console.WriteLine("Password is OK, please enter"); } else { Console.WriteLine("Incorrect password"); } } }