Delphi passing parameters by reference or by value/copy

后端 未结 3 951
轮回少年
轮回少年 2021-01-02 02:59

Context 1

var text:String;

text:=\'hello\';

myFunc(text);

Context2

function myFunc(mytext:String);
var textcopy:String;
b         


        
3条回答
  •  余生分开走
    2021-01-02 03:25

    In Delphi to pass by reference you explicitly add the var keyword:

    procedure myFunc(var mytext:String);
    

    This means that myFunc can modify the contents of the string and have the caller see the changes.

提交回复
热议问题