Re: parametize the "is" keyword
- From: "Horacio N. Hdez." <hnh12358@xxxxxxxxx>
- Date: 30 Jan 2007 08:55:56 -0800
Hi,
You can use the typeof,
something like this
private void foo(Type arg)
{
foreach (Control uc in _displayPanel.Controls)
{
if (typeof(uc) is arg)
uc.Visible = true;
else
uc.Visible = false;
}
}
And you can use it:
Type theType = typeof(bar);
foo(theType);
_____________________________
http://elblogdehoracio.blogspot.com
On 30 ene, 17:42, newcome...@xxxxxxxxx wrote:
Hi,
I understand how to use the "is" keyword straight forward.
like: if (obj is MyClass1)
However, I would like to parametize the "is"'s argument. Basically, I
would to replace MyClass1 with an argument. Here is an example:
private void foo(WhatType arg)
{
foreach (Control uc in _displayPanel.Controls)
{
if (uc is arg)
uc.Visible = true;
else
uc.Visible = false;
}
}
And call foo like...
foo(MyClass1);
My trouble is, I don't know what is the "arg"'s type? i.e. what
should "WhatType" be?
Is this is even possible?
Thanks for any pointer.
Minh (MCP)
.
- Follow-Ups:
- Re: parametize the "is" keyword
- From: newcomer2k
- Re: parametize the "is" keyword
- References:
- parametize the "is" keyword
- From: newcomer2k
- parametize the "is" keyword
- Prev by Date: Re: How to audit application actions.
- Next by Date: Re: ServiceController and ExecuteCommand
- Previous by thread: Re: parametize the "is" keyword
- Next by thread: Re: parametize the "is" keyword
- Index(es):
Relevant Pages
|