判断输入的信息是否为空,如果为空,提示信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TestDemo1
{
    class Program
    {
        public static string[] name=new string[1];//声明一个长度为一的字符串类型的数组
        static void Main(string[] args)
        {
            name[0] = Console.ReadLine();//输入一个字符串
            while (string.IsNullOrWhiteSpace(name[0]))//判断是否输入的字符串是否为空或者都是空格
            {
                  Console.WriteLine("请重新输入");
                  name[0] = Console.ReadLine();
            }
            
            Console.ReadKey();
        }
    }
}

发布了14 篇原创文章 · 获赞 10 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/qq_36545099/article/details/64123392