T
Tony
Hello!
Here I have a simple question.
Below I have a method handler for event TextChanged called
textBox_TextChanged
If event TextChanged is trigged for a TextBox where the name property is set
to textBoxOccupation
than this statement will be true
if (tb == textBoxOccupation)
Console.WriteLine("Equal without name");
But this seems strange because tb is just a reference to the instance.
I prefer using this statement and check the name property with the right
literal here textboxbccupation
if (tb.Name.ToLower() == "textboxbccupation")
Console.WriteLine("Equal with name");
So now to my question how is it possible to use this statement tb ==
textBoxOccupation
when tb is just an address it's not a name ?
private void textBox_TextChanged(object sender, EventArgs e)
{
TextBox tb = (TextBox)sender;
if (tb == textBoxOccupation)
Console.WriteLine("Equal without name");
if (tb.Name.ToLower() == "textBoxOccupation")
Console.WriteLine("Equal with name");
}
//Tony
Here I have a simple question.
Below I have a method handler for event TextChanged called
textBox_TextChanged
If event TextChanged is trigged for a TextBox where the name property is set
to textBoxOccupation
than this statement will be true
if (tb == textBoxOccupation)
Console.WriteLine("Equal without name");
But this seems strange because tb is just a reference to the instance.
I prefer using this statement and check the name property with the right
literal here textboxbccupation
if (tb.Name.ToLower() == "textboxbccupation")
Console.WriteLine("Equal with name");
So now to my question how is it possible to use this statement tb ==
textBoxOccupation
when tb is just an address it's not a name ?
private void textBox_TextChanged(object sender, EventArgs e)
{
TextBox tb = (TextBox)sender;
if (tb == textBoxOccupation)
Console.WriteLine("Equal without name");
if (tb.Name.ToLower() == "textBoxOccupation")
Console.WriteLine("Equal with name");
}
//Tony