Programming Course in C# ¡Free!

Password as string

 Saturday, April 06, 2013 published by Exercises C#
Proposed exercise

Write a program to ask the user for his/her name and his/her password (both must be strings) and repeat it as many times as necessary, until the entered name is "user" and the password is "password".



using System;
public class PasswordString
public static void Main()
string user, password;

Console.Write("Enter a user: ");
user = Console.ReadLine();

Console.Write("Enter a password: ");
password = Console.ReadLine();
while ( user != "user" && password != "password" );

Console.WriteLine( "Bye!" );