Do a case-sensitive comparison of two objects of the same type in CSharp

Description

The following code shows how to do a case-sensitive comparison of two objects of the same type.

Example


//from  w  ww . j  av  a2s . c  om
using System;
using System.Collections;
using System.Globalization;

public class SamplesComparer  {

   public static void Main()  {
      String str1 = "bbb";
      String str2 = "aaa";
      Console.WriteLine(Comparer.DefaultInvariant.Compare( str1, str2 ) );
   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Collections »




ArrayList
BitArray
Collection
Comparer
HashSet
Hashtable
LinkedList
List
ListDictionary
OrderedDictionary
Queue
SortedList
SortedSet
Stack
StringCollection
StringDictionary