更新时间:2021-07-14 07:10:42
使用它..
Int32.Parse [
use this..
Int32.Parse[^]
(1)存在Int32.TryParse [
(1) There''s the Int32.TryParse[^] method for that (please read the documentation).
(2) OnceTryParse
returnstrue
you have the integer and you may test if it is less than zero.
尝试一下,
Try this,
int checkNumber;
if (int.TryParse(TextBox2.Text, out checkNumber) == false)
{
//Entered number is not interger;
}
else
{
if (Convert.ToInt16(TextBox2.Text) < 0)
{
//Entered no. is negative
}
else
{
//Entered no. is positive
}
}