在delphi中,C#也是如此,对象的地址与对象变量(引用)的地址不是同一个概念。要加以区别。
procedure TForm1.btn1Click(Sender: TObject);
var
p1: Pointer;
p2: Pointer;
begin
if TObject(btn1) = TObject(btn2) then ShowMessage( 'The same as ')
else ShowMessage( 'Dfferent ');
p1 := @btn1;
P2 := @btn2;
if p1 = p2 then ShowMessage( 'The same as ')
else ShowMessage( 'Dfferent ');
end;
转自:https://blog.csdn.net/diligentcatrich/article/details/7077294