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 static class and sealed class in c#?
What is the difference between constants and read-only?
What is a console application in c#?
What are the advantages of generics in c#?
How many aware interfaces are there?
How do you create dlls in .NET
Is it possible to have different access modifiers on the get/set methods of a property in c#?
What is difference between hashtable and dictionary in c#?
If a class derives from another class, will the derived class automatically contain all the public, protected, and internal members of the base class?
Explain constructor in c#?
Is c# and c same?
What are the 3 different types of arrays?
explain the features of static/shared classes.
What is a generic in c#?
What are strongly typed objects?