Sdílet prostřednictvím


Char.Equals Method (Object)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

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

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

Syntax

'Declaration
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 nulla 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

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.