I am learning C# and i am writing a text based game.
I would like to know if its possible to have 1 line of code (Console.WriteLine method) but outputs a message from my game with the players given name with a different color so it kinda highlights it.
This is my current simple code for the message:
Console.WriteLine("Can you survive, {0}?", player.GetName(); //player.Getname() just returns the name of the user
This asks the user for his name:
string name = null;
string input = null;
Console.WriteLine("Before you can start your journey, you will have to enter your name.");
while(input != "Y")
{
if( input == null || input == "N" )
{
Console.WriteLine("Please enter your name and press enter:");
name = Console.ReadLine();
}
Console.WriteLine("Your name is {0}",name);
Console.WriteLine("Is this correct? (y/n)");
input = Console.ReadLine();
input = input.ToUpper();
}
I could only find one answer to this but that is an answer from 2 years ago.. so maybe it is changed?
Thanks in advance if you know the answer.