Description |
Returns true if ObjA and ObjB refer to the same Object instance, or if both are Nil. Otherwise false is returned.
|
| Notes | Static methods are not methods of an object - they are simply class functions or procedures available at any time.
|
|
Microsoft MSDN Links |
System
System.Object
|
|
|
A simple example |
program Project1;
{$APPTYPE CONSOLE}
var
str1, str2, str3 : String;
begin
str1 := 'Delphi';
str2 := 'Basics';
str3 := 'Basics';
if System.Object.ReferenceEquals(str1, str2)
then Console.WriteLine('str1 refers to the same object as str2')
else Console.WriteLine('str1 does not refer to the same object as str2');
if System.Object.ReferenceEquals(str1, str3)
then Console.WriteLine('str1 refers to the same object as str3')
else Console.WriteLine('str1 does not refer to the same object as str3');
if System.Object.ReferenceEquals(str2, str3)
then Console.WriteLine('str2 refers to the same object as str3')
else Console.WriteLine('str2 does not refer to the same object as str3');
Console.ReadLine;
end.
| Show full unit code | str1 does not refer to the same object as str2
str1 does not refer to the same object as str3
str2 refers to the same object as str3
|
|
|
|