Re: Using a control as part of an exression

Steve Johnson <[email protected]>
Newsgroups gmane.comp.windows.devel.dotnet.winforms
Message-ID <[email protected]>
On 4/16/07, samir parekh <[email protected]> wrote:
>
> same in c# as well
>
> private void do_Something(Control c)
> {
> if(typeof(c) is ListBox)
> {
>
> }
> elseif(typeof(c) is -----any other type of framework compatible class)
> {
>
> }
>


That won't work.  The typeof operator yields a System.Type, which ListBox
will never match.  Do this instead:

if(c is ListBox)...

--
Steve Johnson
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.