2

I have a class with protected constructor. Is there any possibilities to access this class from another class

Base Class :

    public class BaseClass
    {
    private static ClassA _classA = new ClassA();
    private static ClassB _classB= new ClassB();
    protected BaseClass(ClassA _classA, ClassB _classB)
    {
        _classA = classA;
        _classB= classB;
    }

This is my Derived Class :

    public class DerivedClass : BaseClass
    {

    }

Derived class require to pass parameter. How to solve it.

2
  • 2
    Possible duplicate of Passing parameters to the base class constructor Commented Jan 25, 2019 at 11:57
  • 1
    Are you sure your BaseClass looks like that? It is very odd to have an instance constructor that overwrites static variables like that. Commented Jan 25, 2019 at 11:58

1 Answer 1

2
public class DerivedClass : BaseClass
{
    public DerivedClass(ClassA classA, ClassB classB) : base(classA, classB)
    {

    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.