") } 我收到类似这样的错误消息:value is too small or too big for-6ren">
gpt4 book ai didi

c# - 整数解析

转载 作者:行者123 更新时间:2023-11-30 14:04:32 26 4
gpt4 key购买 nike

我需要为值为 < = 2147483647 的文本框编写验证

我的代码是这样的:

Textbox1.Text = "78987162789"

if(Int32.Parse(Textbox1.text) > 2147483647)
{
Messagebox("should not > ")
}

我收到类似这样的错误消息:value is too small or too big for Int。我该如何解决这个问题?

最佳答案

有一个 TryParse哪种方法更适合该目的。

int Val;
bool ok = Int32.TryParse (Textbox1.Text, out Val);
if (!ok) { ... problem occurred ... }

关于c# - 整数解析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1753626/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com