FastFoodCoding

Login


Connect with one of the following accounts





Login

Please wait while we redirect...

Views: 47   



Following program shows you how to compare two strings are equal by ignoring the case.
In this program we get two different cases of strings from user and shows those strings are equal by using string1.Equals(string2, StringComparison.OrdinalIgnoreCase)

using System;

class MainClass {
  public static void Main (string[] args) {
    Console.WriteLine("Please enter first string:");
    string string1 = Console.ReadLine();
    Console.WriteLine("Please enter second string:");
    string string2 = Console.ReadLine();
    if (string1.Equals(string2,StringComparison.OrdinalIgnoreCase)) {
      Console.WriteLine("Given strings are equal");
    } else {
      Console.WriteLine("Given strings are not equal");
    }
  }
}

Output:

Example1:

Please enter first string:
 tom
Please enter second string:
 TOM
Given strings are equal

Example2:

Please enter first string:
 tom
Please enter second string:
 jenni
Given strings are not equal



On By


Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News