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.





















Home »
  C# Tutorial »
    Data Types »




C# Data Types
Bool
Byte
Char
Decimal
Double
Float
Integer
Long
Short
String
C# Array
Array Example
Byte Array
C# Standard Data Type Format
BigInteger
Complex
Currency
DateTime
DateTimeOffset
DateTime Format Parse Convert
TimeSpan
TimeZone
Enum
Null
tuple
var