• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 681
  • Last Modified:

Case insensitive comparison on textbox value in C#

I am simply trying to run a comparison on the value entered into a textbox. I want the comparison to not care about the case in which the value was entered. ("OPEN" vs "open") So my comparison currently looks like this:
if (textbox1.text == 'open')
}
do this logic
}

How do I make it case insensitive ? I have read I can use String.Compare to do this. But I can't seem to find the correct syntax. Any help would be greatly appreciated.

Jason
0
jazzcatone
Asked:
jazzcatone
  • 2
1 Solution
 
oxyooCommented:
Hi,
Try this...

if (System.String.Compare(textbox1.text,"open", true) == 0 )
}
do this logic
}

Open in new window

0
 
oxyooCommented:
0
 
xiyuzuCommented:
textBox1.Text.ToLower().Trim() == "open"
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now