[Solved] Using if to compare strings c#


This code just doesn’t make sense. You’re entering AS but then checking if it can be converted to a long as part of your condition for equality. Just do this;

public static void Main (string[] args)
{
   string pass = "AS";

   if (Console.ReadLine() == pass)
       Console.WriteLine("hi");
}

Then, if you want to put that in a loop or whatever go for it. But I recommend starting with the simplest most basic thing. When you run this program and enter AS it will print hi

1

solved Using if to compare strings c#