Development · Native API migration preview · Coverage validation in progress Published release →

API Browser

Method

ReferenceEquals

static func ReferenceEquals(left: object?, right: object?) -> bool

Declaring type: Object
Module: System
Assembly: System.Runtime.dll
Source file: Object.rvn

Tests whether two supported references denote the same underlying object or are both null.

Parameters

Name Type Description
left Object? A class, array, String or boxed-value reference, or null.
right Object? A class, array, String or boxed-value reference, or null.

Return value

Boolean

True for aliases or two nulls; false for distinct allocations or exactly one null.

Remarks

The reference parameters are nullable for Raven compatibility: ReferenceEquals(Object? left, Object? right). This annotation does not introduce a distinct runtime type. Nonvirtual and independent of Equals overrides. Separate boxes remain distinct even with equal contents. String compares shared text owners, not temporary wrapper allocations or contents. Aliases remain identical through conversions; independently constructed equal strings are distinct. There is no automatic literal interning; explicit String.Intern canonicalizes text within one execution. Managed byref locations are not Object identity operands.