第1个回答 2013-11-12
数值型字符串(例"123")转换成数值(例123),short, int, float 等数值类型均有一个 static parse() 函数。这个函数就是用来将字符串转换为相应数值的。
(例: float f = float.parse("123.23"); )
第2个回答 2013-11-12
建议用 int.TryPares
如:
int n;
string s="123";
int n1;
string s1="abc";
int.TryPares(s,out n);
int.TryPares(s1,out n1);
结果 n=123;
n1=0;本回答被网友采纳
第3个回答 2020-03-17
如果是在文本框中(txtNum)输入“123”,用int.parse(txtNum.Text);
string
i="123";int
a=convent.toInt32(i);这样比较容易实现。
第4个回答 2013-11-12
Convert.ToInt32(字符串);
就这样写就可以了。
第5个回答 2013-11-12
int.prase(你要转换的字符串)