小技巧(一)分离字符串string str="(1,10,100,1000,10000,)";
Posted on 2006-05-14 16:17 且行且思 阅读(561) 评论(0) 编辑 收藏 举报string str="(1,10,100,1000,10000,)";
str=str.Trim('(').Trim(')').Trim(',');//去掉开头和结尾的“(”、“)”和“,”
string[] strArr=str.Split(',');
for(int i=0;i<strArr.Length;i++)
{
Response.Write(strArr[i]+"<br>");
}
str=str.Trim('(').Trim(')').Trim(',');//去掉开头和结尾的“(”、“)”和“,”
string[] strArr=str.Split(',');
for(int i=0;i<strArr.Length;i++)
{
Response.Write(strArr[i]+"<br>");
}
输出为
1
10
100
1000
10000
+++++++++++++++++++++++++++++++++
double ab=Convert.ToDouble(this.TextBox1.Text);
double ac=Convert.ToDouble(this.TextBox2.Text);
this.Label1.Text = Convert.ToDouble(ab / (ab + ac)).ToString("0.00%");