将字符串列表转换为单个字符串 [英] Convert a list of strings to a single string
本文介绍了将字符串列表转换为单个字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
List<string> MyList = (List<string>)Session["MyList"];
MyList
包含以下值:12
34
55
23
.
MyList
contains values like: 12
34
55
23
.
我尝试使用下面的代码,但是值消失了.
I tried using the code below, however the values disappear.
string Something = Convert.ToString(MyList);
我还需要将每个值都用逗号(",
")分隔.
I also need each value to be separated with a comma (",
").
如何将List<string> Mylist
转换为string
?
推荐答案
string Something = string.Join(",", MyList);
这篇关于将字符串列表转换为单个字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文