#region 把字符串转换为整数,或者双精度浮点类型 522
int age;
string s = "20";
// 字符串转换为整型 变成32为的整型
age = Convert.ToInt32(s);
Console.WriteLine("字符串转换为32位整型:"+age);
float weight;
double height;
s = "80.5";
weight = Convert.ToSingle(s);
Console.WriteLine("字符串转换为单精度浮点类型:"+weight);
//变成双精度数字类型
s = "1.78";
height = Convert.ToDouble(s);
Console.WriteLine("字符串转换为双精度浮点类型"+height);
#endregion
效果