我有一個獲取字符串的代碼,該字符串包含顏色名稱。我想分割用逗號分隔的字符串。這裏是我的代碼。用逗號分隔的字符串
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