Equivalent of 'InstanceSize' function in PascalABC.Net?

This code is derived from a Delphi/Lazarus) tutorial. It appears that InstanceSize causes an error in PascalABC.Net - "The type ‘Human’ does not contain a definition for ‘InstanceSize’ "… Is there an equivalent function in PascalABC.Net?

Этот код взят из учебника по Delphi/Lazarus). Похоже, что InstanceSize вызывает ошибку в PascalABC.Net - "Тип ‘Human’ не содержит определения для ‘InstanceSize’ "… Есть ли эквивалентная функция в PascalABC.Net?

Gary

program ObjectTest;

//uses StrUtils;

Type
  Human = class
    private
      Name : string;
    public
  end;

 var
   Person : Human;
 begin
   Person := Human.Create;
   Write('Input a name: ');
   Readln(Person.Name);
   Writeln(Person.Name);
   Writeln('Instance size: ', Person.InstanceSize);  
   Readln
 end.
type
  t1 = record
    b: byte;
    i: integer;
  end;
  
begin
  sizeof(t1).Println;
end.

There is no sizeof for classes tho because it wouldn’t make sense under .Net . Byte size is only needed if you are planning to manage memory yourself, but class memory is managed by GC.

2 лайка

Thank you Sun_Serega. That’s understandable. So there is really no sense in using functions like “Person.Free” or “FreeAndNil(Person)” which this particular Delphi/Lazarus tutorial covers, since .Net uses a GC.

Спасибо, Sun_Serega. Это понятно. Значит, действительно нет смысла использовать функции типа “Person.Free” или “FreeAndNil(Person)”, которые рассматривает данный учебник по Delphi/Lazarus, поскольку .Net использует GC.

3 лайка