转换列表< INT>以逗号分隔字符串 [英] Converting a List<int> to a comma separated string
本文介绍了转换列表< INT>以逗号分隔字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法把一个列表,并将其转换成一个逗号分隔字符串?
我知道我可以循环并构建它,但不知何故,我觉得有些你们的干什么呢?
$一个更冷静的方式b $ b
我真的想学习这些类型的'招数',所以请解释或连结您使用的方法的文档。
解决方案
列表< INT>列表= ...;
的string.join(,,list.Select(N =方式> n.ToString())ToArray的())
Is there a way to take a List and convert it into a comma separated string?
I know I can just loop and build it, but somehow I think some of you guys a more cool way of doing it?
I really want to learn these types of 'tricks', so please explain or link to the docs on the method you use.
解决方案
List<int> list = ...;
string.Join(",", list.Select(n => n.ToString()).ToArray())
这篇关于转换列表< INT>以逗号分隔字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文