Char.Equals Method (Object)

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Returns a value indicating whether this instance is equal to a specified object.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

Syntax

Public Overrides Function Equals ( _
    obj As Object _
) As Boolean
public override bool Equals(
    Object obj
)

Parameters

  • obj
    Type: System..::.Object
    An object to compare with this instance or nullNothingnullptra null reference (Nothing in Visual Basic).

Return Value

Type: System..::.Boolean
true if obj is an instance of Char and equals the value of this instance; otherwise, false.

Remarks

The comparison performed by this method is based on the encoded values of this instance and obj, not necessarily their lexicographical characteristics.

Examples

The following example demonstrates Equals.


Module Example

   Public Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)

      Dim chA As Char
      chA = "A"c
      Dim chB As Char
      chB = "B"c

      outputBlock.Text &= chA.Equals("A"c) & vbCrLf     ' Output: "True"
      outputBlock.Text &= "b"c.Equals(chB) & vbCrLf     ' Output: "False"

   End Sub

End Module
using System;

public class Example
{
   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
   {
      char chA = 'A';
      char chB = 'B';

      outputBlock.Text += chA.Equals('A') + "\n";       // Output: "True"
      outputBlock.Text += 'b'.Equals(chB) + "\n";       // Output: "False"
   }
}

Version Information

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Platforms

Windows Phone

See Also

Reference

Char Structure

Equals Overload

System Namespace

Char..::.CompareTo