Hi, I want to declare a string value in a WPF application.
Example:
private void button1_Click(object sender, RoutedEventArgs e)
{
if (textBox1.Text == "Name")
{
label1.Content = "This is " + textBox1.Text;
}
}
If the user enter NAME/ name/ Name the if condition should apply and give the corresponding output
ie. label1 should display This is Name/ NAME/etc.
Loading

Sanjeeb LenkaRank #301 · 8.3K reputationPosted Feb 19, 2014, 10:59 PM EST
if (textBox1.Text.ToUpper() == "NAME")
{
label1.Content = "This is " + textBox1.Text;
}
theLizardRank #1,079 · 1.8K reputationPosted Feb 20, 2014, 11:01 AM EST
If TextBox1 should always be upper case or lower case for that matter, then all you need to do is
TextBox1.Text = textBox1.Text.ToUpper();
OR simply
label1.Content = "This is " + textBox1.Text.ToUpper();
Adarsh Balachandran26 reputationPosted Feb 20, 2014, 6:40 PM EST
if (textBox1.Text == "Name")
{
label1.Content = "This is " + textBox1.Text;
}
else
{
label1.Content = "This is not my " + textBox1.Text;
}
If I enter name in the text box, it will satisfy only the else condition and will display This is not my name. Instead of that it has to display This is my name. That is the first if condition statement should work for names, Name, NAME, nAME, etc.