Yeah, I "clicked" yesterday that I should be using ClassType which is working correctly for my purpose.
Cheers. From: delphi-boun...@delphi.org.nz [mailto:delphi-boun...@delphi.org.nz] On Behalf Of Jolyon Smith Sent: Wednesday, 26 January 2011 9:11 AM To: 'NZ Borland Developers Group - Delphi List' Subject: Re: [DUG] Object is Object vs Object.Classname = 'Object' The two are not comparable in function so cannot really be compared for efficiency: if a is b then Will evaluate true if a is an instance of b or of any class derived from b. if (abc.Classname = 'TMyObject') then Will evaluate true only if abc is an instance of TMyObject and only if the classname of TMyObject uses the exact capitalisation in the comparison string. So it depends what you are trying to do... if you need to test for an instance being of a specific class and only a specific class then the ClassName comparison is valid, but a more efficient and more type-safe alternative would be: if (a.ClassType = TMyObject) then But if you need to detect when a is of class TMyObject or some class that ultimately derives from TMyObject, then an is or InheritsFrom() test is the only option.
_______________________________________________ NZ Borland Developers Group - Delphi mailing list Post: delphi@delphi.org.nz Admin: http://delphi.org.nz/mailman/listinfo/delphi Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: unsubscribe