Adding a setter to a derived interface

前端 未结 4 813
清酒与你
清酒与你 2020-12-09 02:11

Is it possible somehow to achieve this behavior in C#:

public interface IReadOnly
{
    Data Value { get; }
}

internal interface IWritable : IReadOnly 
{
           


        
4条回答
  •  臣服心动
    2020-12-09 02:48

    For this to work well, one should declare and implement an IReadWrite, which inherits both IReadable and IWritable, and includes a "new" read-write property. Otherwise an interface that has separate get and set properties, but no get-set property, will be neither readable nor writable.

提交回复
热议问题