如何验证控制台输入为整数?
我已经编写了我的代码,我想以这样的方式对其进行验证,它只允许插入内容而不是字母。这是代码,请你帮助我。谢谢。
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace minimum{
class Program
{
static void Main(string[] args)
{
int a = Convert.ToInt32(Console.ReadLine());
int b = Convert.ToInt32(Console.ReadLine());
int c = Convert.ToInt32(Console.ReadLine());
if (a < b)
{
if (a < c)
{
Console.WriteLine(a + "is the minimum number");
}
}
if (b < a)
{
if (b < c)
{
Console.WriteLine(b + "is the minimum number");
}
}
if (c < a)
{
if (c < b)
{
Console.WriteLine(c + "is the minimum number");
}
}
Console.ReadLine();
}
}}
白衣染霜花
慕哥6287543
温温酱
有只小跳蛙
随时随地看视频慕课网APP
相关分类