C# 中如何将List里的集合转换成字符串并按指定的字符进行分隔?

C# 中如何将List<string>里的集合转换成字符串并按指定的字符进行分隔?

代码:

复制代码

using System;
using System.Collections.Generic;
publicclassMyClass
{
publicstaticvoidMain()
{
List<string> names =newList<string>(){"ccc","xxx","aaa","bbbb"};
names.Sort();
var result =String.Join(",", names.ToArray());
Console.Write(result);
Console.ReadKey();
}
}

复制代码

效果:http://ideone.com/eTQ99L

参考:

我的C#在线编辑器及代码

C# List<string> to string with delimiter

猜你喜欢

转载自blog.csdn.net/cxu123321/article/details/93395164