从 TDictionary 类中获取所有键作为单个字符串
有没有更聪明的方法(用更少的代码)从 TDictionary 中获取所有键作为单个字符串,以逗号分隔
var
FDicList : TDictionary <String, Integer>;
KeyStrList: TStringlist;
KeyName: string;
begin
/// result as comma text
KeyStrList := TStringlist.Create;
try
for KeyName in FDicList.Keys do
KeyStrList.Add(KeyName);
All_keys_as_string := KeyStrList.CommaText;
finally
KeyStrList.Free;
end;
end;
is there any smarter way ( with less code) to go get all keys from a TDictionary as a single string, comma separated
var
FDicList : TDictionary <String, Integer>;
KeyStrList: TStringlist;
KeyName: string;
begin
/// result as comma text
KeyStrList := TStringlist.Create;
try
for KeyName in FDicList.Keys do
KeyStrList.Add(KeyName);
All_keys_as_string := KeyStrList.CommaText;
finally
KeyStrList.Free;
end;
end;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只要键本身不包含逗号,您就可以编写:
As long as the keys don't contain a comma itself you can just write: