尝试解析不接受10位数 [英] Try parse is not accepting 10 digits

查看:77
本文介绍了尝试解析不接受10位数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在下面的代码中,在textbox16中,如果输入1234567890(10位数 - 手机号码),则会失败。如果我输入123456789(9digits)就行了!任何人都可以帮助我。



 受保护  void  TextBox16_TextChanged( object  sender,EventArgs e) //  移动号码更改 
{
int value ;
if Int32 .TryParse(TextBox16.Text, out value )== false
{
// TryParse调用无法将值转换为整数,
}
else
{
v_mobile = TextBox16.Text;
}
}





谢谢。

解决方案

< blockquote>请阅读: Int32.MaxValue [ ^ ]。

Quote:

此常量的值为2,147,483,647;也就是十六进制0x7FFFFFFF。





我建议使用字符串,因为格式不同。例如,如果您想打电话给波兰,您需要提供一个电话号码,例如: +48 000000000 - 用于手机。



Quote:

今天的大多数电话网络(例外是私人内部通信和安全电话网络)在国际电话网,其中电话号码的格式由ITU-T在E.164建议书中标准化。 这指定整个数字应<15>或更短 ,并以国家/地区前缀开头。对于大多数国家而言,其后是区号或城市代码和用户号码,其可能包括特定电话交换机的代码。 ITU-T E.123建议书描述了如何以加号(+)和国家代码开头的书面或印刷国际电话号码。从固定电话拨打国际号码时,+必须替换为拨打电话所在国家/地区选择的国际电话号码。 有些手机允许直接输入





更多: http://en.wikipedia.org/wiki/Telephone_number [ ^ ]

http://en.wikipedia .org / wiki / Telephone_numbers_in_Poland [ ^ ]


原因是:

http://msdn.microsoft.com/en-us/library/system.int32.maxvalue.aspx [ ^ ]

请尝试使用Int64:

http ://msdn.microsoft.com/en-us/library/system.int64.maxvalue.aspx [ ^ ]


尝试使用长变量而不是Int64.TryParse


In the following code , in textbox16, if I enter 1234567890 (10 digit - mobile number) it fails. If I enter 123456789 (9digits) it works! Can anyone help me out.

protected void TextBox16_TextChanged(object sender, EventArgs e)   // mobile number changing
    {
        int value;
        if (Int32.TryParse(TextBox16.Text, out value) == false)
        {
            // TryParse call fails to convert the value to an integer,
        }
        else
        {
            v_mobile = TextBox16.Text;
        }
    }



Thanks.

解决方案

Please, read this: Int32.MaxValue[^].

Quote:

The value of this constant is 2,147,483,647; that is, hexadecimal 0x7FFFFFFF.



I would suggest to use string, because of different formatting. For example, if you want to make call to Poland, you need to provide a telephone number, like: +48 000000000 - for mobile-phone.

Quote:

Most telephone networks today (exceptions being private intercom and secure phone networks) are interconnected in the international telephone network, where the format of telephone numbers is standardized by ITU-T in the recommendation E.164. This specifies that the entire number should be 15 digits or shorter, and begin with a country prefix. For most countries, this is followed by an area code or city code and the subscriber number, which might consist of the code for a particular telephone exchange. ITU-T recommendation E.123 describes how to represent an international telephone number in writing or print, starting with a plus sign ("+") and the country code. When calling an international number from a fixed line phone, the + must be replaced with the international call prefix chosen by the country the call is being made from. Some mobile phones allow the + to be entered directly.



More: http://en.wikipedia.org/wiki/Telephone_number[^]
http://en.wikipedia.org/wiki/Telephone_numbers_in_Poland[^]


The reason is:
http://msdn.microsoft.com/en-us/library/system.int32.maxvalue.aspx[^]
Try Int64 instead:
http://msdn.microsoft.com/en-us/library/system.int64.maxvalue.aspx[^]


Try using a long variable instead and Int64.TryParse


这篇关于尝试解析不接受10位数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆