Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Migrating from Delphi 7 to Delphi dotnet

8 views
Skip to first unread message

jerinvarghese

unread,
Jul 30, 2008, 6:50:52 AM7/30/08
to
 Hi,

I am migrating an application from Delphi 7 to dotnet (Delphi 2005).
Could anyone suggest how to deal with the following piece of code

function sortfunction(A, B: Pointer):integer;
begin
Result := 0;
if TMyObject(A).GetKey < TMyObject(B).GetKey then
Result := -1
else
Result := 1;
end;

When compiled in Delphi2005, I'm getting an E2089 InValid typecast error
Is this not supported in dotnet? if so can anyone suggest a workaround
please
I'm having many descendent classes of TMyObject, all of which are using
the sort function

--- posted by geoForum on http://delphi.newswhat.com

Stephen Boyd

unread,
Jul 30, 2008, 8:33:43 AM7/30/08
to
Try passing A and B as references to TMyObject.

function sortfunction(A,B: TMyObject): Integer; ...

Marc Rohloff [TeamB]

unread,
Jul 30, 2008, 9:11:57 AM7/30/08
to
On Wed, 30 Jul 2008 11:50:52 +0100, jerinvarghese wrote:

> I am migrating an application from Delphi 7 to dotnet (Delphi 2005).
> Could anyone suggest how to deal with the following piece of code
>
> function sortfunction(A, B: Pointer):integer;

> When compiled in Delphi2005, I'm getting an E2089 InValid typecast error


> Is this not supported in dotnet? if so can anyone suggest a workaround
> please

For .NET the sort function must be defined as:
function sortfunction(A, B: TObject):integer;
Additionally it can now be an object method or class function.

--
Marc Rohloff [TeamB]
marc -at- marc rohloff -dot- com

jerinvarghese

unread,
Jul 31, 2008, 5:16:18 AM7/31/08
to
thanks very much, I changed the function to
function sortfunction(A, B: TObject):integer;

It worked, :)

0 new messages