C# If Equals Case insensitive
boolean, c#, case, if-statement
Solution
You could use this
string.Equals(one, two, StringComparison.CurrentCultureIgnoreCase)
Your code would be
if (string.Equals(one, two, StringComparison.CurrentCultureIgnoreCase))
{
MessageBox.Show("Pass");
}
else
{
MessageBox.Show("Fail");
}
Using CurrentCultureIgnoreCase :
Compare strings using culture-sensitive sort rules, the current culture, and ignoring the case of the strings being compared.
More info here
Problem
The following code will open up a Message Box containing the word "Fail". Is there a way to make the if statement case insensitive, so that the if statement passes and opens a mbox containg "Pass" without converting the character/string to upper/lower case? here is the code: ``` public partial class Form1 : Form { string one = "A"; string two = "a"; public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { if (one == two) { MessageBox.Show("Pass"); } else { MessageBox.Show("Fail"); } } } ``` Thanks in advance