Click here to Skip to main content
15,890,506 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My doubt, why it is not possible to access a protected constructor which is in a base class from a derived class? i would like to know why there is a visibility restriction when its a derived class and the base class constructor using protected specifier??

What I have tried:

namespace BaseConcept
{
  class Basse
  {
    public int check;
    public Basse(int check)
   {
     this.check = check;
   }
    protected Basse()
    {
      Console.WriteLine("Base Constructor");
    }
  }
  class Program:Basse
  {
    public Program():base()
    { }
    
    public Program(int value):base(value)
    {

    }
    static void Main(string[] args)
    {
      Basse b1 = new Basse();              //This is where my doubt arise.
      Basse b= new Basse(10);             
      Program p = new Program();
     Program p1 = new Program(10);
     Console.WriteLine(" " + p1.check); 
    }
  }
}
Posted
Updated 2-Nov-17 11:02am

1 solution

 
Share this answer
 

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