you could do this by overloading your method.
public string MyMethod(Button bc)
{
return "Button";
}
public string MyMethod(TextBox tb)
{
return "TextBox";
}
This is one of the easiest ways to do this.
--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik
Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Max André Bündchen" <.> wrote in message
news:ec**************@TK2MSFTNGP11.phx.gbl...
Hi,
I must design a method that receive a Control object and return a single
value if it is a TextBox object, another value if it is a ComboBox object
and so on.
If I try a "if-else-if" loop, this will be very unhappy! Can I use a
foreach to make that? How declare and create the array for use in the operator
"is" (for test a Control, like "cont is TextBox")?
Thanks,
Max