Char.Equals Char.Equals Char.Equals Char.Equals Method

定義

傳回值,這個值表示這個執行個體是否等於指定的物件或 Char 值。Returns a value that indicates whether this instance is equal to a specified object or Char value.

多載

Equals(Char) Equals(Char) Equals(Char) Equals(Char)

傳回值,表示這個執行個體是否等於指定的 Char 物件。Returns a value that indicates whether this instance is equal to the specified Char object.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

傳回值,這個值指出此執行個體是否與指定的物件相等。Returns a value that indicates whether this instance is equal to a specified object.

Equals(Char) Equals(Char) Equals(Char) Equals(Char)

傳回值,表示這個執行個體是否等於指定的 Char 物件。Returns a value that indicates whether this instance is equal to the specified Char object.

public:
 virtual bool Equals(char obj);
public bool Equals (char obj);
override this.Equals : char -> bool
Public Function Equals (obj As Char) As Boolean

參數

obj
Char Char Char Char

與這個執行個體相比較的物件。An object to compare to this instance.

傳回

true 參數等於這個執行個體的值時為 obj,否則為 falsetrue if the obj parameter equals the value of this instance; otherwise, false.

實作

備註

這個方法System.IEquatable<T>會實作用介面,而且執行Char.Equals(Object)效果稍微優於,因為它obj不需要將參數取消裝箱。This method implements the System.IEquatable<T> interface, and performs slightly better than Char.Equals(Object) because it does not need to unbox the obj parameter.

另請參閱

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

傳回值,這個值指出此執行個體是否與指定的物件相等。Returns a value that indicates whether this instance is equal to a specified object.

public:
 override bool Equals(System::Object ^ obj);
public override bool Equals (object obj);
override this.Equals : obj -> bool
Public Overrides Function Equals (obj As Object) As Boolean

參數

obj
Object Object Object Object

與這個執行個體或 null 相比較的物件。An object to compare with this instance or null.

傳回

如果 trueobj 的執行個體,並且等於這個執行個體的值,則為 Char,否則為 falsetrue if obj is an instance of Char and equals the value of this instance; otherwise, false.

範例

下列程式碼範例將Equals示範。The following code example demonstrates Equals.

using namespace System;
int main()
{
   char chA = 'A';
   char chB = 'B';
   Console::WriteLine( chA.Equals( 'A' ) ); // Output: "True"
   Console::WriteLine( 'b'.Equals( chB ) ); // Output: "False"
}

using System;

public class EqualsSample {
    public static void Main() {
        char chA = 'A';
        char chB = 'B';

        Console.WriteLine(chA.Equals('A'));		// Output: "True"
        Console.WriteLine('b'.Equals(chB));		// Output: "False"
    }
}
Module EqualsSample

    Sub Main()

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

        Console.WriteLine(chA.Equals("A"c))     ' Output: "True"
        Console.WriteLine("b"c.Equals(chB))     ' Output: "False"

    End Sub

End Module

備註

這個方法所執行的比較是根據這個實例obj的編碼值,而不一定是它們的字典特性。The comparison performed by this method is based on the encoded values of this instance and obj, not necessarily their lexicographical characteristics.

另請參閱

適用於