将Char数组定义为常量?

问题描述 投票:0回答:1

我在Delphi 10.3.3中使用此功能:

function StrTrimCharsLeft(const S: string; const Chars: array of Char): string;
var
  I, L: SizeInt;
begin
  I := 1;
  L := Length(S);
  while (I <= L) and ArrayContainsChar(Chars, S[I]) do
    Inc(I);
  Result := Copy(S, I, L - I + 1);
end;

当我以这种方式使用该函数时,出现错误([dcc32错误]:E2250没有重载版本的'StrTrimCharsLeft',可以使用这些参数来调用]:] >>

const
    BomChars = ['ï', '»', '¿'];
...
s := JclStrings.StrTrimCharsLeft(s, BomChars);

但是当我以这种方式使用它时,一切正常,没有错误:

s := JclStrings.StrTrimCharsLeft(s, ['ï', '»', '¿']);

那么如何定义和使用Char数组作为常量?

我在Delphi 10.3.3中使用此函数:StrTrimCharsLeft(const S:string; const Chars:Char数组):string; var I,L:SizeInt;开始我:= 1; L:=长度(S);而(I <= L)和...

arrays delphi constants delphi-10.3-rio
1个回答
0
投票

写作时

© www.soinside.com 2019 - 2024. All rights reserved.