string str1 = "12345678987654321"; string temp = ""; int num = 0; for(int i=0;i<str1.Length;i++) { temp = str1[i].ToString();//得到每个数字 num = num + Convert.ToInt32(temp);//累积相加 } Response.Write("总和为" + num + "");