Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

Comparing strings using compareTo() in C#

The example below explains the comparison of two strings.
The comparing result will be in integer.

0 means equals.
1 means not equals.

  1.  
  2. using System;
  3.  
  4. namespace ConsoleApplication1
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10.  
  11. string name1 = "code";
  12. string name2 = "code";
  13.  
  14. int i =name1.CompareTo(name2);
  15.  
  16. Console.WriteLine(i);
  17. }
  18.  
  19. }
  20. }


Output:
0


..