字符串不正确格式问题 [英] string not correct format issue
本文介绍了字符串不正确格式问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hi
Convert.ToInt64(NumTestCaseText.Text)我收到的问题字符串不正确。 br />
可以对此有任何帮助..
解决方案
如果输入字符串格式错误(即它不代表有效的Int64
)然后您所能做的就是优雅地处理FormatException
,例如要求用户再次输入文本。
也许你应该检查null和空:
转换.ToInt64(!string.IsNullOrEmpty(NumTestCaseText.Text)?NumTestCaseText.Text: 0);
只是一个猜测,真的 - 不知道了,它可能是任何东西......
< blockquote>试试这个...... :)
int result = 0 ;
int .TryParse(NumTestCaseText.Text, out result)
hi
Convert.ToInt64(NumTestCaseText.Text) i am getting the issue string not correct form at with this.
can any one help on this..
解决方案
If the input string format is wrong (that is it not represent a validInt64
) then all you can do is handle theFormatException
gracefully, for instance asking the user to enter again the text.
Maybe you should check for null and empty:
Convert.ToInt64(!string.IsNullOrEmpty(NumTestCaseText.Text) ? NumTestCaseText.Text : "0");
Just a guess, really - without knowing any more, it could be anything...
try this...:)
int result=0; int.TryParse(NumTestCaseText.Text,out result)
这篇关于字符串不正确格式问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文