What is the difference between readonly and const
Answer Posted / chandan kumar
The read only keyword is different from the const keyword. A
const field can only be initialized at the declaration of
the field. A read only field can be initialized either at
the declaration or in a constructor. Therefore, read only
fields can have different values depending on the
constructor used. Also, while a const field is a
compile-time constant, the read only field can be used for
runtime constants as in the
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
What is the difference between a class and an object c#?
What is constants in c#?
Why to use “finally” block in c#?
Why static constructor is parameterless in c#?
What does ienumerable mean?
What is enumerable in c#?
What is the difference between read and readline in c#?
Why is c# used?
What is difference between list and ilist in c#?
What are the main reasons to use c# language?
How to use nullable types in .net?
Explain lock, monitors, and mutex object in threading.
What is default value of enum c#?
Why delegates are required?
What is the difference between protected and internal in c#?