您当前的位置: 首页 > 

Peter_Gao_

暂无认证

  • 0浏览

    0关注

    621博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

整数类型转换 Convert long to int

Peter_Gao_ 发布时间:2020-12-28 15:36:49 ,浏览量:0

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.

关注
打赏
1664521772
查看更多评论
立即登录/注册

微信扫码登录

0.1154s