转换列表<&诠释GT;为分隔字符串列表 [英] Convert List<int> to delimited string list
本文介绍了转换列表<&诠释GT;为分隔字符串列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:结果
的最优雅的方式返回从列表℃的字符串; INT>
我不知道最简单的方法来做到这一点。我只是想添加一个;在每个值之间吐出来作为一个字符串。我不明白,你可以使用的ToString做到这一点()。我想通过必须循环,并创建一个StringBuilder并追加&安培;添加一个;
I'm not sure the easiest way to do this. I simply want to add a ; between each value and spit it out as one string. I don't see that you can do this with ToString(). I'd have to loop through and create a stringbuilder and append & add a ";".
推荐答案
更新时间:使用列表< INT> ;
而不是列表与LT;串>
使用字符串。加入
:
List<int> data = ..;
var result = string.Join(";", data); // (.NET 4.0 only)
var result = string.Join(";", data.Select(x => x.ToString()).ToArray()); // (.NET 3.5)
这篇关于转换列表<&诠释GT;为分隔字符串列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文