Difficulty: Easy
Correct Answer: const float pi = 3.14F;
Explanation:
Introduction / Context:
Constants in C# are compile-time values that cannot change after compilation. This question asks which syntax properly defines an immutable numeric constant.
Given Data / Assumptions:
Concept / Approach:
Use const for compile-time constants. A const must be assigned at declaration. #define in C# only defines a conditional compilation symbol, not a numeric macro as in C/C++.
Step-by-Step Solution:
Verification / Alternative check:
Attempting to reassign pi when declared const produces a compile-time error, proving immutability.
Why Other Options Are Wrong:
They either define mutable data or use invalid/unsupported syntax.
Common Pitfalls:
Confusing const with readonly (readonly allows assignment in constructor at run time; const is compile-time).
Final Answer:
const float pi = 3.14F;
Discussion & Comments