C# .net , winforms application., Visual studio 2010
I have created a control c which can be Textbox or combobox. now i want to type cast c dynamically that if sender is combobox than typecast c with combobox, if sender is textbox make c as textbox.
Here is the sample code for performing this, but i am looking for better way.
If you have pls suggest..
Now i am doing in this way
private void Test(Object sender, EventArgs e)
{
Control c = sender as Textbox(); //assuming sender is textbox
if( c== null)
{
c = sender as ComboBox(); // assuming sender is combobox
}
}
// I want better way.
for example
c = sender as Combobox() || sender as Textbox //Like this