on-internet
← Community

Why does a class property with a non-public setter fail to implement an interface property?

Stack Overflow ·

I am trying to create a property on a class that is protected. This property is also defined by an interface that the class implements. public interface IStat<T> { public T Offset { get; protected set; } } public class Stat : IStat<float> { public float Offset { get; protected set; } = 0.0f; } However, this causes an error: 'Stat' does not implement interface member 'IStat.Offset.set'. 'Stat.Offset.set' is not public. CS0277 Removing the access modifier from the class property fixes the error Removing the access modifier from the interface property changes nothing Removing the access modifier

Comments

Sign in or sign up to comment and upvote.

No comments yet.