C# String Equality

Description

String Equality determines whether two specified strings have the same value.

Syntax

String.Equality has the following syntax.


public static bool operator ==(
  string a,
  string b
)

Parameters

String.Equality has the following parameters.

  • a - The first string to compare, or null.
  • b - The second string to compare, or null.

Returns

String.Equality method returns true if the value of a is the same as the value of b; otherwise, false.

Example

The following example demonstrates the equality operator.


/*w  w  w.j  av  a2 s .c o  m*/
using System;

class EqualityOp 
{
    public static void Main() 
    {

        String  Lower = "abcd";

        Console.WriteLine( Lower == "abcd");
    }
}

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