0

"The readonly Modifier", Which statements are true?

1. readonly fields can be initialized only when declared. 2. readonly fields can be initialized by the constructor. 3. constants should be assigned a value when declared. 4. constants can be initialized by the constructors. I am stuck on this question. plz help me guys..

9th Jan 2023, 6:29 AM
Katchi Mohamed Mohamed Hanan
Katchi Mohamed Mohamed Hanan - avatar
1 ответ
+ 1
Option 2 and 3 are correct Constants must be initialized like const string str = "Hello World"; readonly fields can be initialized with the conrructor but does not have to be initialized when declared
9th Jan 2023, 6:38 AM
Ab SH