我有一个获取字符串的代码,该字符串包含颜色名称。我想分割用逗号分隔的字符串。这里是我的代码。用逗号分隔的字符串
public static string getcolours()
{
string str = null;
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))
{
}
else
{
str = str + missingpath;
}
}
return str;
}
试着向上看“C#string split”。 - http://msdn.microsoft.com/en-us/library/tabh47cf.aspx – 2013-04-24 14:56:13
string.Split(',') – Indy9000 2013-04-24 14:56:38
只是谷歌你的标题... – ken2k 2013-04-24 14:57:02