C# StringComparer Equals(Object, Object)

Description

StringComparer Equals(Object, Object) when overridden in a derived class, indicates whether two objects are equal.

Syntax

StringComparer.Equals(Object, Object) has the following syntax.


public bool Equals(
  Object x,
  Object y
)

Parameters

StringComparer.Equals(Object, Object) has the following parameters.

  • x - An object to compare to y.
  • y - An object to compare to x.

Returns

StringComparer.Equals(Object, Object) method returns true if x and y refer to the same object, or x and y are both the same type of object and those objects are equal; otherwise, false.

Example


using System;//from w w w  .  ja  v  a 2  s  .c  om

class Sample 
{
    public static void Main() 
    {
        StringComparer invCmp =   StringComparer.Ordinal;
        
        Console.WriteLine(invCmp.Compare(StringComparer.Ordinal,StringComparer.InvariantCulture));
    }

}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version