ReferenceEqualityComparer Class

Definition

An IEqualityComparer<T> that uses reference equality (ReferenceEquals(Object, Object)) instead of value equality (Equals(Object)) when comparing two object instances.

C#
public sealed class ReferenceEqualityComparer : System.Collections.Generic.IEqualityComparer<object>, System.Collections.IEqualityComparer
Inheritance
ReferenceEqualityComparer
Implements

Remarks

The ReferenceEqualityComparer type cannot be instantiated. Instead, use the Instance property to access the singleton instance of this type.

Properties

Instance

Gets the singleton ReferenceEqualityComparer instance.

Methods

Equals(Object, Object)

Determines whether two object references refer to the same object instance.

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetHashCode(Object)

Returns a hash code for the specified object. The returned hash code is based on the object identity, not on the contents of the object.

GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to

Product Versions
.NET 5, 6, 7, 8, 9