Junior — Middle
How to determine the maximum number of interfaces that a class can implement in a programming language?
sobes.tech AI
Answer from AI
In C#, there is no fixed limit on the number of interfaces a class can implement. Theoretically, a class can implement any number of interfaces.
However, in practice, consider:
- Readability and maintainability of the code.
- Possible conflicts of method names from different interfaces.
Example of implementing multiple interfaces:
interface IA { void MethodA(); }
interface IB { void MethodB(); }
class MyClass : IA, IB {
public void MethodA() { /* implementation */ }
public void MethodB() { /* implementation */ }
}