What would I place after my variable to make the Console.WriteLine ("You input Y")
appear on a different line? Here's the code:
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();
}
Thanks!
You can use
Environment.NewLine
which is a string that acts... as a newline.
Alternatively you can just use
Console.WriteLine()
with no parameters, if a single newline is all you want.
Console.WriteLine();
没有任何参数。
Console.WriteLine("\\r\\nYou input Y");
the problem is since you are reading a key character it will perform output right after the input.
console.writeline() will work as well
In line with the comments on the question, you can do this in both C# and C++
if(something)
{
doThis();
}
else if(somethingElse)
{
doSomethingElse();
}
else
{
kickChuckNorrisInTheTeeth();
}
if/else if/else is all supported in C# and C++
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.