Search code examples
c#stringalphabet

How to neglect Capital and small alphabet in all


string usertype;
usertype = Console.ReadLine();

if (usertype== "Yahoo")
{ 
  Console.WriteLine("You typed Yahoo therefore we are now login to Yahoo Page");
  Console.ReadLine();
}

Nothing wrong with t he code except: If user types Yahoo then it shows answer. I want user; if he types yahoo then answer should be the same.


Solution

  • string usertype;
    usertype = Console.ReadLine();
    
    if (string.Equals(usertype,"Yahoo",StringComparison.OrdinalIgnoreCase))
    { 
      Console.WriteLine("You typed Yahoo therefore we are now login to Yahoo Page");
      Console.ReadLine();
    }