Comparing Strings - CSharp Language Basics

CSharp examples for Language Basics:string

Description

Comparing Strings

Demo Code

using System;// www .j ava 2  s. c om
class MainClass {
   static void Main(string[] args) {
      string str1 = "This is test";
      string str2 = "This is text";
      if (String.Compare(str1, str2) == 0) {
         Console.WriteLine(str1 + " and " + str2 +  " are equal.");
      } else {
         Console.WriteLine(str1 + " and " + str2 + " are not equal.");
      }
      Console.ReadKey() ;
   }
}

Result


Related Tutorials