Click here to Skip to main content
15,848,264 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a parent base class which has an overloaded constructor that creates the instances of another class "GlobalParameters" where I have some common properties I use.

public class base 
{
   public base()
  {
    

  }

  public base(GlobalParameters global)
 {

    global = (GlobalParameters )Activator.CreateInstance(typeof(GlobalParameters ));

 }

}

//here is my GlobalParameters class
public class GlobalParameters()
{
   public string name {get; set;}
   public int age {get; set;)


}

//here is the child class where I want to call the overloaded constructor and use the properties I have in my "GlobalParameters" class

public void ChildClass : Base
{

     //how to call the overload Base constructor and use the global parameter to access those class 
    properties like name and age
    

}


What I have tried:

public base(GlobalParameters global) : this()
 {

    global = (GlobalParameters )Activator.CreateInstance(typeof(GlobalParameters ));

 }


but now how can I call it in the Base class??
Posted
Updated 2-Jul-20 1:14am

1 solution

 
Share this answer
 
Comments
CPallini 2-Jul-20 6:55am    
5.
Richard MacCutchan 2-Jul-20 7:06am    
I think we should be giving these points to Google. :)
CPallini 2-Jul-20 7:19am    
Nah, that's 'expertise'.
:-)

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