So, in my quest to learn C#, I am attempting to create an interactive story that changes based on some of the input that the user had submitted. If the user types in "Bobby" in this case, the narrator begins to talk like Hank Hill. However, with how it's programmed, the input is case sensitive.
I have tried one thing suggestion that I saw which was to format the if statement as:
if (boyName.ToUpper() == "Bobby")
But that did not trigger the if command with different letter cases
Console.WriteLine($"{beginning} \n What was the boy's name?");
boyName = Console.ReadLine();
if (boyName == "Bobby")
{
Console.WriteLine("That boy ain\'t right, I tell ya what... ");
Console.ReadKey();
Console.WriteLine($"{boyName} boy dang climbed a big ol' tree...");
Console.ReadKey();
}
else
{
Console.WriteLine($"The kid named {boyName} climbed a tree...");
Console.ReadKey();
}
I expect to have a line of code that will trigger the if condition no matter the case. However, everything I tried has not changed that. It needs to be specifically "Bobby" or it will trigger the else condition
You should try
if (boyName.ToUpper() == "Bobby".ToUpper())