StringComparer.Equals 方法

定义

当在派生类中重写时,指示两个对象或字符串是否相等。When overridden in a derived class, indicates whether two objects or strings are equal.

重载

Equals(Object, Object)

当在派生类中重写时,指示两个对象是否相等。When overridden in a derived class, indicates whether two objects are equal.

Equals(String, String)

当在派生类中重写时,指示两个字符串是否相等。When overridden in a derived class, indicates whether two strings are equal.

Equals(Object, Object)

当在派生类中重写时,指示两个对象是否相等。When overridden in a derived class, indicates whether two objects are equal.

public:
 virtual bool Equals(System::Object ^ x, System::Object ^ y);
public:
 bool Equals(System::Object ^ x, System::Object ^ y);
public bool Equals (object? x, object? y);
public bool Equals (object x, object y);
override this.Equals : obj * obj -> bool
Public Function Equals (x As Object, y As Object) As Boolean

参数

x
Object

要与 y 比较的对象。An object to compare to y.

y
Object

要与 x 比较的对象。An object to compare to x.

返回

Boolean

如果 xy 引用同一对象,或者 xy 是相同的对象类型且这些对象相等,或者 xy 都是 null,则为 true;否则为 falsetrue 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, or both x and y are null; otherwise, false.

实现

注解

由于运行时不需要取消装箱 xy 它们是值类型,或者如果 x y 它们是引用类型,则尝试向向下转换或向下转换字符串, Equals(String, String) 方法可能比方法更有效 Equals(Object, Object)Because the runtime does not have to unbox x or y if they are value types or attempt to downcast x or y to strings if they are reference types, the Equals(String, String) method may be slightly more efficient than the Equals(Object, Object) method.

适用于

Equals(String, String)

当在派生类中重写时,指示两个字符串是否相等。When overridden in a derived class, indicates whether two strings are equal.

public:
 abstract bool Equals(System::String ^ x, System::String ^ y);
public abstract bool Equals (string x, string y);
public abstract bool Equals (string? x, string? y);
override this.Equals : string * string -> bool
Public MustOverride Function Equals (x As String, y As String) As Boolean

参数

x
String

要与 y 比较的字符串。A string to compare to y.

y
String

要与 x 比较的字符串。A string to compare to x.

返回

Boolean

如果 xy 引用同一对象,或者 xy 相等,或者 xy 均为 null,则为 true;否则为 falsetrue if x and y refer to the same object, or x and y are equal, or x and y are null; otherwise, false.

实现

注解

由于运行时不需要取消装箱 xy 它们是值类型,或者如果 x y 它们是引用类型,则尝试向向下转换或向下转换字符串, Equals(String, String) 方法可能比方法更有效 Equals(Object, Object)Because the runtime does not have to unbox x or y if they are value types or attempt to downcast x or y to strings if they are reference types, the Equals(String, String) method may be slightly more efficient than the Equals(Object, Object) method.

适用于