- 人气:
- 放大
- 缩小
- 二维码
- 赞赏
delphi TArray<TArray<string>> 用法
uses Generics.Collections, Generics.Defaults;
function ParseStyles(const style: string): TArray>;
var
sa, sa2: TArray;
I: Integer;
begin
if style = '' then
SetLength(Result, 0, 0);
sa := style.Split([';']);
SetLength(Result, Length(sa), 2);
for I := 0 to High(sa) do
begin
sa2 := sa[I].Split([':']);
if Length(sa2) = 2 then
begin
Result[I, 0] := sa2[0];
Result[I, 1] := sa2[1];
end;
end;
end;
function GetStyle(const key: string; const styles: TArray>): string;
var
I: Integer;
begin
for I := 0 to High(styles) do
begin
if styles[I,0] = key then
begin
Exit(styles[I, 1]);
end;
end;
Result := '';
end;
procedure TForm16.FormCreate(Sender: TObject);
begin
caption:=GetStyle('红色',ParseStyles('红色:红色路径'));
end;
//国外看到得片段。