Consider the following classes:
public class Vehicle { ... } public class Coverage { ... } public class VehicleList : IEnumerable<Vehicle> { ... } public class CoverageList : IEnumerable<Coverage> { ... } public abstract class Quote { protected VehicleList vehicles; protected CoverageList coverages; internal Quote() { ... } public IReadOnlyCollection<Vehicle> Vehicles { get { return this.vehicles.AsReadOnly(); } } public IReadOnlyCollection<Coverage> Coverages { get { return this.coverages.AsReadOnly(); } } ... } public sealed class OhQuote : Quote {
Quote fully encapsulates the functionality of both VehicleList and CoverageList , so I would like to mark these classes as internal . The problem is that they are protected field types of the public class. If I mark these fields as protected internal , then they are protected OR internal . I really need them to be protected AND internal (with protected with priority in the assembly). You can see that neither Quote (which has an internal constructor) nor its subclasses (which are sealed ) can be extended outside the assembly. I already figured out how to achieve the desired functionality using public interfaces, but I would like to make sure that there is no more concise way.
inheritance protected c # oop
andrew.cuthbert
source share