如何从Delphi函数返回多个值

Delphi函数通常返回单个值,但可以通过变量参数(Var Parameters)、输出参数(Out Parameters)或返回记录来实现返回多个值。Var参数允许函数修改传入变量的值,Out参数则忽略初始值并设置新值。返回记录类型变量是另一种返回多个值的方法,例如,函数WhereAmI可以返回包含纬度和经度的记录。
摘要由CSDN通过智能技术生成

A most common construct in a Delphi application would be a procedure or a function. Known as routines, procedures or functions are statement blocks you call from different locations in a program.

Delphi应用程序中最常见的构造是过程或函数 。 从程序中不同位置调用的语句块称为例程,过程或函数。

Simply put a procedure is a routine not returning a value while a function returns a value.

简单地说,过程是例程,函数返回值时不返回值。

A return value from a function is defined by the return type. In most cases you would write a function to return a single value that would be an integer, string, boolean or some other simple type, also return types could be an array, a string list, an instance of a custom object or alike.

函数的返回值由返回类型定义。 在大多数情况下,您将编写一个函数以返回单个值 ,该可以是整数,字符串,布尔值或其他一些简单类型,返回类型也可以是数组,字符串列表,自定义对象的实例等。

Note that even if your function returns a string list (a collection of strings) it still returns a single value: one instance of the string list.

请注意,即使你的函数返回一个字符串列表(集合字符串 ),它仍会返回一个值:字符串列表中的一个实例。

Further, Delphi routines can really have many faces: Routine, Method, Method Pointer, Event Delegate, Anonymous method...

此外,Delphi例程确实可以有很多面Kong:例程,方法,方法指针,事件委托,匿名方法...

函数可以返回多个值吗? ( Can a Function Return Multiple Values? )

The first answer that comes to mind is no, simply because when we think of a function, we think of a single return value.

我想到的第一个答案是不,仅仅是因为当我们想到一个函数时,我们想到的是一个单一的返回

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值