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;

posted @ 2017-07-25 14:10  坤霸天下  阅读(381)  评论(0编辑  收藏  举报