[Solved] Compare two strings to a value in C# [closed]
I’d advise against using == to test string equality. Use String.Equals() instead. You can also do this in one statement using Linq: if ((new [] {string1, string2, …}).Any(s=>string.equals(s,”No”,StringComparison.CurrentCultureIgnoreCase))) { DoStuff(); } This will DoStuff() if any of your strings are equal to “no” ignoring the case. See String.Equals() and Enumerable.Any() for further reading. It should … Read more