Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

How to pass a class as an argument of a function?

$
0
0
Hi there, currently I'm creating a new sub-window once, in the body of the main window constructor:
PopUp hey = new PopUp();


However, for my needs, this needs to be done in another function along with some other things; more importantly, this function has to be able to create several different sub-windows(e.g. PopUp, HelpWindow, EnterSomeInfo, etc.). I tried this:
        public CreateWindow( Form which)
        {
            which frm = new which();
//....


but I get

Quote

The type or namespace 'which' could not be found. Are you missing a using directive or an assembly reference?

I followed these two links:
http://en.csharp-online.net/CSharp_FAQ:_Am_I_missing_an_assembly_reference
http://blogs.msdn.com/b/csharpfaq/archive/2004/04/29/123028.aspx
but they didn't help me much as I need 'which' to be able to refer to several different forms.
Changing
public CreateWindow( Form which)

to
public CreateWindow( class which)

or
public CreateWindow( object which)

also throws similar errors. How can I pass a class(or rather, form) as an argument of a function?

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>