Click here to Skip to main content
15,877,618 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I have seen a code as shown below

Class Sample
    {
         AddSubPage("Title",new ServerControl());
         private void AddSubPage(string title, Control subPage)
         {

         }
    };
    Class ServerControl
    {
       public ServerControl()
       {
           InitializeComponent();
       }
    };


My doubt is regarding the second parameter.What is actually passing in the

second parameter.I know 'Control' is the base class of all controls in form.So how

to assign new ServerControl() to Control object.

'new ServerControl()' means just calling a constructor.(See the code).Then what is

actually passing here.

Thanks in advance
Posted
Updated 25-Nov-11 17:22pm
v2

1 solution

Your example is incomplete, the ServerControl class does not derive from anything so it has no base class. I'll assume you meant for it to derive from Control.

new ServerControl() will create an object of type ServerControl and pass it to the AddSubPage method. Since it is derived from Control it has an is a relationship. ServerControl is a Control. This is a basic object oriented concept, if you don't understand it then I would suggest learning OO before proceeding.
 
Share this answer
 
Comments
kutz 2 25-Nov-11 23:40pm    
ServerControl class inherit a class called DBMigrationSubPageBase.And this DBMigrationSubPageBase inherits from 'UserControl'
kutz 2 28-Nov-11 1:00am    
Please give a reply to above comment

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900