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;

所以在使用的时候得注意,尤其是数据库 查询的时候,为了避免各种问题
本文来自博客园,作者:del88,转载请注明原文链接:https://www.cnblogs.com/del88/p/4356755.html
浙公网安备 33010602011771号