Multiple choice technology programming languages

Features of Read only variables?

  1. It is allocated at compile time

  2. Declaration and initialization is separated

  3. It is allocated at runtime

  4. All of these

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

In C#, readonly variables are allocated when their containing type is loaded, which can be at compile time for constant-like scenarios. The key distinction from const is that readonly fields can be initialized at declaration or in a constructor, while const requires compile-time initialization. Option C contradicts A, and B is a feature (not a defining characteristic), making A the most accurate among the choices.