You will repeatedly ask the user to enter a password until the user enters the correct one.
To write the loop, you use the do-while construction.
using System; class Program/*from w w w.ja v a2s . c om*/ { static void Main(string[] args) { string correctPassword = "friend"; bool ok; do { Console.Write("Enter password: "); string enteredPassword = Console.ReadLine(); // Evaluating ok = enteredPassword == correctPassword; } while (!ok); // loop repeats when the condition holds Console.WriteLine("Come inside, please..."); } }