Compare string read from console in CSharp
Description
The following code shows how to compare string read from console.
Example
/*from w w w .ja va2s .co m*/
using System;
public class StringConcatenation2
{
static void Main(string[] args)
{
Console.WriteLine("Enter Your Password?");
string UserPassword = Console.ReadLine();
string Password = "Victory";
if(Password.CompareTo(UserPassword) == 0)
{
Console.WriteLine("Bad Password");
}
Console.WriteLine("Good Password!");
}
}
The code above generates the following result.