What is the difference between readonly and const
Answer Posted / sabina
both meant for constant values. a const field can only be
initialized at the declaretion of the field. a read only
field can be initialized either in initialization or in
constructer. therefore , reaadonly field can have different
values depending on the constructure used
also a const field is compile time constant , readonly
field can be used for runtime constants
| Is This Answer Correct ? | 18 Yes | 2 No |
Post New Answer View All Answers
What does readonly mean in c#?
How to move to a state-related codebase?
Can I fly with a loop recorder?
Why does dllimport not work for me?
What is the purpose of abstract class in c#?
What is the .NET collection class that allows an element to be accessed using a unique key?
Can struct be static in c#?
Can hashtable have duplicate keys?
In c#, what will happen if you do not explicitly provide a constructor for a class?
Why do we use anonymous method in c#?
Is a char?
What is the default value of date?
Explain partial class in c#?
How do I run managed code in a process?
How to find the current application file path while runtime?