CommaText 在没有指定StrictDelimiter=true的情况下,当列表中项中 包含 空格和逗号的时候就默认的 在这个字符串上面 增加 双引号 很智能吧

例子1:

var
  MyList: TStringList;
begin
  MyList := TStringList.Create;
  try
    MyList.Add('a b c');
    MyList.Add('d,e,f');
//    MyList.Add('abc');
//    MyList.Add('def');
    ShowMessage(MyList.CommaText);
  finally
    MyList.Free;
  end;
end;

 

例子2:

var
  MyList: TStringList;
begin
  MyList := TStringList.Create;
  try
    MyList.Delimiter := ',';
    MyList.StrictDelimiter := True;
    MyList.Add('a b c');
    MyList.Add('d,e,f');
//    MyList.Add('abc');
//    MyList.Add('def');
    ShowMessage(MyList.DelimitedText);
  finally
    MyList.Free;
  end;
end;

 

例子3:

var
  MyList: TStringList;
begin
  MyList := TStringList.Create;
  try
//    MyList.Delimiter := ',';
//    MyList.StrictDelimiter := True;
//    MyList.Add('a b c');
//    MyList.Add('d,e,f');
    MyList.Add('abc');
    MyList.Add('def');
    ShowMessage(MyList.CommaText);
  finally
    MyList.Free;
  end;
end;

 

所以在使用的时候得注意,尤其是数据库 查询的时候,为了避免各种问题

posted on 2015-03-22 09:42  del88  阅读(201)  评论(0编辑  收藏  举报