I have the following code in all of my controllers:
public class PackagesController : BaseController
{
private IAccountService _account;
private IDataSourceService _dataSource;
private IPackageService _package;
private IProductService _product;
private IContentService _content;
private ISequenceService _sequence;
They all inherit from BaseController. I’m a bit confused about the difference between public, private and protected. I am thinking I could move these into BaseController. If I did this then should I use private, protected or is there some other modifier.
You would use Protected if you wanted the derived classes to have access. Private would prevent even the derived classes from accessing, which is not what you want. Public would let any code access them, which is not needed here, as you typically do not need access to Controller members from outside.