I'm trying to create a program in c# that asks the user a question and then tells him if he is correct or incorrect, the code I am using only allows for case to be the same. Is there a way I can compare two strings without it checking for case. Here is some of my code

      Console.Write("List the first sahabi who was promised paradise \n(hint he was Prophet Muhammad (peace be upon him)'s                            best friend: ");
      answer = Console.ReadLine();
      if (answer == "Abu Bakr")
      {
         Console.WriteLine("That is correct good job!\n\n");
         ++score;
      }

You can use the ToUpper() or ToLower() on the input and then compare it to the correct answer in that same case. For example...

 if (answer.ToLower() == "abu bakr")
Comments
Thanks a bunch

I think what you want is something like this:

        Console.Write("List the first sahabi who was promised paradise \n(hint he was Prophet Muhammad (peace be upon him)'s best friend: ");
        answer = Console.ReadLine();
        if(answer.ToLower() == "abu bakr")
        {
            Console.WriteLine("That is correct good job!\n\n");
            ++score;
        }

This converts the answer to all lower case and compares it to the right answer present in lower case.

Comments
Thank you so much! Big help
This question has already been answered. Start a new discussion instead.