C# 中如何将List<string>里的集合转换成字符串与字符串怎样转为List<string>集合
1.把List<string>里的集合转换成字符串:
List<string> names =newList<string>(){"ccc","xxx","aaa","bbbb"}; names.Sort(); var result =String.Join(",", names.ToArray()); Console.Write(result);
2.字符串怎样转为List<string>集合:
string s = "1,2,3";
List<string> list = new List<string>(s.Split(','));
foreach (string t in list)
{
MessageBox.Show("*" + t + "*");
}