C# 如何检查字符串是否不等于布尔值

C# 如何检查字符串是否不等于布尔值,c#,string,boolean,C#,String,Boolean,嗨,伙计们,我想检查用户输入(字符串)是否不等于布尔值,但显然不能这样做: 例如: using System; using System.Linq; namespace SymbolCheck { class Program { static void Main(string[] args) { String symbol = Console.ReadLine(); int value;

嗨,伙计们,我想检查用户输入(字符串)是否不等于布尔值,但显然不能这样做:

例如:

using System;
using System.Linq;

namespace SymbolCheck
{
    class Program
    {
        static void Main(string[] args)
        {
            String symbol = Console.ReadLine();
            int value;
            bool isVowel = "aeiouAEIOU".IndexOf(symbol) >= 0;

            if (int.TryParse(symbol, out value))
            {
                Console.WriteLine("Input is a number: " + symbol);
            }

            else if (symbol.Equals(isVowel) & symbol.Any(char.IsUpper))
            {
                Console.WriteLine("Input is a uppercase vowel: "+ symbol);
            }

            else if (symbol != isVowel)
            {
                Console.WriteLine("Input is a consonant: "+ symbol);
            }

我有办法绕过它,但想知道是否还有其他方法:

    else if (symbol.Equals(isVowel) & symbol.Any(char.IsLower))
    {
        Console.WriteLine("Input is a lowercase vowel: "+ symbol);
    }

    else if (!int.TryParse(symbol, out value) & symbol.Any(char.IsUpper))
    {
        Console.WriteLine("Input is a uppercase consonant: " + symbol);
    }

您可能希望检查这两个条件是否都为真:因此请使用
&
符号。此外,如果is元音是布尔值,那么直接使用它(
symbol.Equals(is元音.ToString()
没有任何意义)

另一张支票是

if (!isVowel)

isvore.ToString();
如果不将其分配给变量,则没有任何用处是的,对。对不起,忘了删除它,我只是在某个点上进行了实验:)打字:
input
而不是
input
谢谢我得到了答案
if (!isVowel)