C# string compare

Last modified: June 29, 2021
static void Main(string[] args) { var v1 = "A"; var v2 = "a"; //this method work but it is slightly take more resources if (v1.ToUpper() == v2.ToUpper()) { Console.WriteLine("Same"); } //this is better approach if (v1.Equals(v2, StringComparison.OrdinalIgnoreCase)) { Console.WriteLine("Same"); } }