小编unk*_*own的帖子

错误1无法将类型'char'隐式转换为'bool'

我已经看到了其他问题,但答案似乎很复杂,无法理解它们,所以继承我的代码:

注意:我是c shar语言的新手

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

namespace Input_Program
{
    class Program
    {
       private static void Main()
       {
           Console.WriteLine("Welcome to my bool program!");
           Console.WriteLine("Input a NON capital y or n when told to.");


            char Y;
            char N;

            if(Y = 'y')
            {}
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

谢谢,谢谢

.net c#

1
推荐指数
1
解决办法
4019
查看次数

相当于c#中的换行符

在我的变量之后放置什么以使其Console.WriteLine ("You input Y") 出现在不同的行上?这是代码:

static void Main()
    {
        Console.WriteLine("Welcome to my bool program!");
        Console.WriteLine("Input a NON capital y or n please.");

        char Y = Console.ReadKey().KeyChar;

        if (Y == 'y')
        {
            Console.WriteLine("You input Y");
        }
        else
        {
            if (Y == 'n')
            {
                Console.WriteLine("You input N");
            }
        }

        Console.WriteLine("Press enter to exit the program, Have a good day!");
        Console.ReadLine();
    }
Run Code Online (Sandbox Code Playgroud)

谢谢!

c# windows

1
推荐指数
1
解决办法
198
查看次数

标签 统计

c# ×2

.net ×1

windows ×1