Difficulty: Easy
Correct Answer: Methods, properties, and events
Explanation:
Introduction / Context:
Virtual members enable derived classes to provide specialized behavior. Misunderstanding which members can be marked virtual leads to incorrect designs and compiler errors.
Given Data / Assumptions:
Concept / Approach:
Virtual is permitted on methods, properties, and events. Fields store data and do not participate in polymorphic dispatch, therefore they cannot be virtual. Static members also do not participate in instance polymorphism.
Step-by-Step Solution:
Verification / Alternative check:
Try compiling 'public virtual int x;' or 'public virtual static int y;'; both will fail. 'public virtual int P { get; set; }' compiles and can be overridden.
Why Other Options Are Wrong:
Any option listing fields or static fields as virtual is invalid in C#.
Common Pitfalls:
Assuming virtual applies to data the same way as to behavior; forgetting that polymorphism targets methods (including property/event accessors).
Final Answer:
Methods, properties, and events
Discussion & Comments