0

Hi, I would like to know how to port this code in Delphi

a : Word;
  b : ^Word;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
  b := @a;
  Inc(b^);
  //Display a
end;

To code in .NET, The problem is converting the pointer.

The Migrating Pointer Types section in the Codegear help gives this example however it does not explain it very well on how to use it.

var
  P: Pointer;
  I: Integer;
begin
  I := 5;
  P := @I;

could be converted to

var
  P: TObject;
  I: Integer;
begin
  I := 5;
  P := TObject(I);
2
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by LizR
0

Other than your initial question seems an overly weird thing to do.. I cant think of why you would ever find yourself in a position to do what that code does.. but .. we'll ignore that..

Everything in .net is an object, so by turning it to a generic "tobject" you have your effective pointer. Does that explain it better?

0

I would just like to know how to create and use a "pointer" in Delphi.NET. If you can give me an example that would be great

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.