我有一个逗号分隔的字符串.如何将其转换为换行符格式.我的字符串很喜欢
red,yellow,green,orange,pink,black,white
Run Code Online (Sandbox Code Playgroud)
我需要格式化这个字符串
red
yellow
green
orange
pink
black
white
Run Code Online (Sandbox Code Playgroud)
这是我的代码
public static string getcolours()
{
List<string> colours = new List<string>();
DBClass db = new DBClass();
DataTable allcolours = new DataTable();
allcolours = db.GetTableSP("kt_getcolors");
for (int i = 0; i < allcolours.Rows.Count; i++)
{
string s = allcolours.Rows[i].ItemArray[0].ToString();
string missingpath = "images/color/" + s + ".jpg";
if (!FileExists(missingpath))
{
colours.Add(s);
}
}
string res = string.Join(", ", colours);
using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"F:\test.txt", true))
{
file.WriteLine(res);
}
return res;
}
Run Code Online (Sandbox Code Playgroud)
有人知道如何格式化吗?
| 归档时间: |
|
| 查看次数: |
6416 次 |
| 最近记录: |