本文介绍了调整Int的长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是:

if (txtMobile.Text != "")
           {
               p.Mobile1 = (Int32.Parse(txtMobile.Text));
           }



我添加一个12345678(八位数)的电话号码,不插入国家代码或区号。

一旦我拿出更多数字,我就会得到Overflow Execption未处理,附加信息:Int32的值太大或太小。



现在我进去试试这个:


Where I add a Phone number with 12345678 (eight digits) not inserting country code or area code.
As soon as I come up with more digits I get " Overflow Execption was unhandled, Additional information: Value was either too large or too small for an Int32".

Now I go in and try this:

if (txtMobile.Text != "")
           {
               p.Mobile1 = (Int64.Parse(txtMobile.Text));
           }



我挥之不去的红线和消息无法将类型'long'隐式转换为'int'。存在明确的转换(你错过了一个演员)



任何想法家伙?


I ger wavey redlines and message that " Can not implicitly convert type 'long' to 'int'. An explict conversion exists(you are missing a cast)"

Any ideas guys ?

推荐答案


+<CountryCode>(0)<AreaCode><LocalNumber>

例如:

Such as:

+44(0)123 4567890

始终存储电话号码字符串中的数字:你可以用它们做有用的数学,所以试图将它们存储为数字是错误的! :笑:

Always store phone numbers in strings: there is no useful maths you can do with them, so trying to store them as numerics is just wrong! :laugh:



这篇关于调整Int的长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-19 02:41