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
Why do we use inheritance in c#?
Is c# good for web development?
What is default class in c#?
What is Named parameter in C#?
Where static variables are stored?
How do I create a multilanguage, single-file assembly?
Can we set image Source dynamically using C# in WPF application?
What is the root element of an xml file?
What is the difference between method and constructor in c#?
What is console writeline in c#?
What is c# best for?
How do I enforce const correctness in c#?
What is protected internal modifier in C#?
Can you access a hidden base class method in the derived class?
What is the benefit of delegate in c#?