I was wondering if someone can help me. I am very new to programming and this is my first time using stackoverflow.
I am looking at creating a while loop that ask the user for a their background and once the input is correct to break out of the loop. I could use break to exit out but I was trying to find another way. My code so far is:
var background = "";
while (background != "M" || background != "W" || background != "R")
{
Console.WriteLine("Welcome " + name + ", " + "Please pick a class: \n" +
"(M)age \n" +
"(W)arrior \n" +
"(R)ogue \n");
var readLine = Console.ReadLine();
if (readLine != null) background = readLine.ToUpper();
if (background == "M")
{
Console.WriteLine("Welcome Mage " + name);
}
else if (background == "W")
{
Console.WriteLine("Welcome Warrior " + name);
}
else if (background == "R")
{
Console.WriteLine("Welcome Rogue " + name);
}
else
{
Console.WriteLine("Invalid choice");
}
}