我必须声明,像这样一个过程:如何检查是否一个动态数组为空
procedure MyProc(List: Array of string);
我想知道如何检查List
参数为空。
例如:
procedure MyProc(List: Array of string);
begin
if List=[] then // here I want to check if the List array is empty
//do something
else
//do something else
end;
我怎样才能做到这一点?
你应该写'MyProc(const List:string of array)',因为在你的代码中,所有的字符串在调用MyProc之前都被复制到一个临时数组中。并且'如果pointer(List)= nil then'是检查动态数组是否为空的最快方法。 – 2011-04-28 06:46:13
'指针(列表)'放弃类型安全并依赖于实现细节 – 2011-04-28 15:51:09