11
2012
04

转换含有逗号的字符串

string[] fanwei = e.Row.Cells[i].Text.Trim().Split(',');
string value = "";
for (int i = 0; i < fanwei.Length; i++)
{
switch (fanwei[i].ToString())
{
case "1": if (value != "") value = value + ","; value = value + "字符串1"; break;
case "2": if (value != "") value = value + ","; value = value + "字符串2"; break;
case "3": if (value != "") value = value + ","; value = value + "字符串3"; break;
}
}
if (value == "")
{
e.Row.Cells[i].Text = fanwei[0].ToString();
}
else
{
e.Row.Cells[i].Text = value;
}
« 上一篇下一篇 »

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。