Overriding interface definitions

75 Views Asked by At

Possible Duplicate:
Why is it impossible to override a getter-only property and add a setter?

Let's say that I got the following interfaces:

public interface IMessage
{
    bool KeepAlive { get; }
}

public interface IRequest : IMessage
{
    bool KeepAlive { get; }
}

The problem is that I want the IReponse interface to have a setter:

public interface IReponse : IMessage
{
    bool KeepAlive { get; set; }
}
  1. Why isn't that allowed?
  2. What kind of problems can I get if I do new bool KeepAlive { get; set; }.

Update:

I read the other question and it says that it's not expected that the property will change. I do not agree. Let's take for instance Socket.Connected property. It has only a getter, but it CAN be changed. What a readonly property says is that the property can only be changed from within the implementation.

0

There are 0 best solutions below