Difficulty: Easy
Correct Answer: class MyClass : IMyInterface { double IMyInterface.MyFun(Single i) { / code / } }
Explanation:
Introduction / Context:
Interfaces declare member signatures. Implementations may be provided either implicitly (public members matching the signature) or explicitly (qualified with the interface name). This item asks you to recognize valid C# syntax for explicit interface implementation.
Given Data / Assumptions:
Concept / Approach:
Explicit interface implementation syntax is: returnType InterfaceName.MemberName(parameters) { ... } and appears within a class that lists the interface after the colon. No access modifier is used on explicit implementations.
Step-by-Step Solution:
Verification / Alternative check:
Compile Option D: succeeds. Attempt A/B/C in a C# project: they fail with syntax errors.
Why Other Options Are Wrong:
Common Pitfalls:
Mixing VB and C# syntax when writing interface implementations; remember explicit implementations omit access modifiers and are qualified by the interface name.
Final Answer:
class MyClass : IMyInterface { double IMyInterface.MyFun(Single i) { / code */ } }
Discussion & Comments