C# if判断输入字符


            while (true)
            {
    
    
                Console.WriteLine("请输入一个字符");
                char ch = Char.Parse(Console.ReadLine());
                if (ch >= 'a' && ch <= 'z')
                {
    
    
                    Console.WriteLine("小写字母");
                }
                else if (ch >= 'A' && ch <= 'Z')
                {
    
    
                    Console.WriteLine("大写字母");
                }
                else if (ch >= '0' && ch <= '9')
                {
    
    
                    Console.WriteLine("数字类型");
                }
                else
                {
    
    
                    Console.WriteLine("其他类型");
                }
            }

猜你喜欢

转载自blog.csdn.net/qq_28058231/article/details/108879132
今日推荐