相关疑难解决方法(0)

如何验证控制台输入为整数?

我已经编写了我的代码,我想以这样的方式对其进行验证,它只允许插入内容而不是字母.这是代码,请你帮助我.谢谢.

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 + …
Run Code Online (Sandbox Code Playgroud)

c# validation console

9
推荐指数
3
解决办法
7万
查看次数

标签 统计

c# ×1

console ×1

validation ×1