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
Explain the access modifiers in c#?
Why attributes are used in c#?
What is a factory in c#?
Can abstract class have parameterized constructor?
What is the use of private constructor in c#?
What is a hash table in c#?
What is the difference between // comments, /* */ comments and /// comments?
Is overriding of a function possible in the same class?
What is the difference between “constant” and “readonly” variables in c#?
Define an abstract class?
How do I create a multi language, multi file assembly?
How to move to a state-related codebase?
how background thread access to ui control?
What does using do in c#?
What is the name of c# compiler?