“Left side cannot be assigned to” for record type properties in Delphi

前端 未结 8 1007
夕颜
夕颜 2020-12-01 16:09

I\'m curious to know why Delphi treats record type properties as read only:

  TRec = record
    A : integer;
    B : string;
  end;

  TForm1 = class(TForm)
         


        
8条回答
  •  青春惊慌失措
    2020-12-01 16:29

    The simplest approach is:

    procedure TForm1.DoSomething(ARec: TRec);
    begin
      with Rec do
        A := ARec.A;
    end;
    

提交回复
热议问题