整数类型转换 Convert long to int
https://stackoverflow.com/questions/5192862/how-to-convert-long-to-int-in-net
You can’t store a 15 digit integer since the maximum value for an integer is 2,147,483,647.
整型存储最大不能超过15位。
You could use TryParse() to get the long
-Value from yout user input:
可以用TryParse() 把一个输入的 string 字符串转换得到一个 long 长整型。
String Am = AmountTextBox.Text.ToString();
long l;
Int64.TryParse(Am, out l);
It will return false
if the text can’t be converted to long
, so it’s pretty safe to use.
如果转换失败,则会返回false, 因此使用这个方法很案例。
Otherwise, converting a long
to int
is a easy as
或者 把一个 长整型转换成整型也很简单:直接在 前面 加 (int)
int i = (int)yourLongValue;
if you’re happy with discarding MSBs and taking LSBs.
还没有评论,来说两句吧...