Below is Parent & Child class.
public class ParentController : ApiController
{
public ICustomer customer { get; set;}
public ICustUtil util { get; set;}
}
public class ChildController : ParentController
{
//no issue here
public string Get()
{
customer = util.GetCustomers();
}
}
If I make the parent class properties as protected & try to use them, I get Object NULL reference Exception
public class ParentController : ApiController
{
protected ICustomer customer { get; set;}
protected ICustUtil util { get; set;}
}
public class ChildController : ParentController
{
//Object Null reference exception at run time here
public string Get(){
customer = util.GetCustomers();}
}
I am trying to understand how does it make difference updating public
to protected
access specifier.
Please note:-
- I am using
Castle Windsor DI
container
Please ignore naming convention for now.