Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个字符串列表
var li = new List<string>() { "word1", "word2", "word3", "word4", "word5", "word6", };
我想在每个单词输出列表中连接一些字符将是
word1#,word2#,word3#,word4#,word5#,word6#
这样做怎么样:
li = li.Select(x => x + "#").ToList();
如果您的意思是要输出字符串“word1#,word2#,word3#,word4#,word5#,word6#”,那么在上述行之后,执行以下操作:
var output = String.Join(",", li);
试试这个
var word = string.Join("#,",li)+"#";
它将加入你的字符串分隔#,
#,