I'm attempting to give a class a protected property. An interface implemented by that class declares the same property too.
public interface IReading<T> {
public T Adjustment { get; protected set; }
}
public class Reading : IReading<float> {
public float Adjustment { get; protected set; } = 0.0f;
}
But the compiler reports this:
'Reading' does not implement interface member 'IReading.Adjustment.set'. 'Reading.Adjustment.set' is not public.
CS0277 (https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS0277))
Taking the access modifier off the class property eliminates the error
Taking the access modifier off the interface property makes no difference
Taking the access modifier off both eliminates the error
I take this to mean C# won't allow me to express this arrangement. Still, I'd really like to understand why I can't require every implementation of the IReading interface to implement this property as a protected member.
I also looked at Why can't a non-public interface member be implemented implicitly? (https://stackoverflow.com/q/68592353) since the problem looked related, although I don't believe my implementation here is implicit.