Difficulty: Easy
Correct Answer: The compiler will report an error since the interface IMyInterface is only partially implemented.
Explanation:
Introduction / Context:
In C#, a non-abstract class that declares it implements an interface must provide implementations for all interface members. Explicit interface implementation is permitted, but completeness is still required.
Given Data / Assumptions:
Concept / Approach:
When a class lists an interface after the colon, the compiler enforces that every declared member of the interface is implemented (either explicitly or implicitly). If any member is missing and the class is not abstract, compilation fails. Declaring the class abstract would defer the unimplemented members to a subclass.
Step-by-Step Solution:
Verification / Alternative check:
Add either an implicit public void fun2() { ... } or an explicit void IMyInterface.fun2() { ... }. Compilation will then succeed.
Why Other Options Are Wrong:
Common Pitfalls:
Forgetting that explicit implementation still requires completeness; it only affects accessibility and call syntax.
Final Answer:
The compiler will report an error since the interface IMyInterface is only partially implemented.
Discussion & Comments