Multiple choice technology programming languages

Among the following choices which is correct about readonly variable in C# code?

  1. It's the same as a constant

  2. It's value can be assigned only once

  3. You can never assign a value to it

  4. You can assign value multiple times

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

A readonly field in C# can only be assigned a value during its declaration or within the class's constructor. Once the constructor finishes, its value becomes immutable. This differs from constants, which must be known at compile-time, and regular variables, which can be reassigned multiple times.