Difficulty: Easy
Correct Answer: True
Explanation:
Introduction / Context:
This focuses on expression usage in C#: values versus statements. A function that returns a value can appear in expressions; a void method cannot, because it yields no value.
Given Data / Assumptions:
Concept / Approach:
Expressions require operands that evaluate to values. Using a void-returning method where a value is expected causes a compile-time error. Void methods are invoked as standalone statements.
Step-by-Step Solution:
Verification / Alternative check:
Try compiling code that assigns the result of a void method; the compiler rejects it.
Why Other Options Are Wrong:
Common Pitfalls:
Assuming any method call can be nested in expressions regardless of return type.
Final Answer:
True
Discussion & Comments