首页 > 代码库 > delphi将两个Strlist合并,求并集

delphi将两个Strlist合并,求并集

Function StrList_Merge(StrListA,StrListB:String):String; //将两个Strlist合并,求并集
var SListA,SListB,SListC:TStringList;
i:Integer;
begin
Result := ‘‘;
Try
SListA := TStringList.Create;
SListB := TStringList.Create;
SListC := TStringList.Create;
SListA.CommaText := StrListA;

SListB.CommaText := StrListB;
SListC.Assign(SListA);
for i:=0 to SListB.Count-1 do begin
if SListC.IndexOf(SListB[i])<0 then SListC.Add(SListB[i]);
end;
Result := SListC.CommaText;
Finally
FreeAndNil(SListA);

FreeAndNil(SListB);

FreeAndNil(SListC);
end;

end;

delphi将两个Strlist合并,求并集