如何处理此错误“价值太大或太小......”? [英] how can I handle this error "Value was either too large or too small.."?

查看:78
本文介绍了如何处理此错误“价值太大或太小......”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户在文本框或gridview单元格等数据输入控件中输入较大值时,如何处理此错误?

How can I handle this error when user enter a large value in data entry controls like textbox or gridview cell?

推荐答案

使用TryParse并报告问题。

所有数字类型都有TryParse方法:int,int64,double,float,...

它们都只返回一个值,只要它有效,并且一个bool说它是否有效。如果失败,请将其报告给您的用户并让他输入有效的号码...
Use TryParse and report a problem.
There are TryParse methods for all numeric types: int, int64, double, float, ...
And they all return a value only if it was valid, and a bool to say if it worked or not. If it fails, report that back to your user and get him to enter a valid number...


这篇关于如何处理此错误“价值太大或太小......”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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