Many times I want to define an interface with some methods that maintain a behavior relationship between them.
However, I feel that many times this relationship is implicit. **Is there any way to enforce this relationship?**
Of course, one could define this behavior as inheritance. But since C# does not allow multiple inheritance, I believe that many times an interface would be more advisable and that inheritance is not flexible enough.
----
For example:
```c#
public interface IComponent
{
void Enable();
void Disable();
bool IsEnabled();
}
```
For this interface, the following relationship should be fulfilled:
- If `Enable()` is called, `IsEnabled()` should return **true**.
- If `Disable()` is called, `IsEnabled()` should return **false**.
---
**For clarification: I want to enforce the constraint that:**
- When implementing `Enable()`, the implementer should ensure that `IsEnabled()` returns **true**
- When implementing `Disable()`, the implementer should ensure that `IsEnabled()` returns **false**
---
**How to enforce this implementation constraint? Is this a sign (a smell) that this design is flawed in some way?**