How to access private methods without helpers?

前端 未结 6 2081
孤独总比滥情好
孤独总比滥情好 2020-11-28 06:39

In Delphi 10 Seattle I could use the following code to work around overly strict visibility restrictions.

How do I get access to private variables?



        
6条回答
  •  我在风中等你
    2020-11-28 07:04

    If you want a clean way that does not impact performance, you still can access private fields from a record helper using the with statement.

    function TValueHelper.GetAsInteger: Integer;
    begin
      with Self do begin
        Result := FData.FAsSLong;
      end;
    end;
    

    I hope they keep this method open, because we have code with high performance demands.

提交回复
热议问题