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
Explain what is copy constructor?
How to sort an int array in c#?
Explain the importance and use of each, version, culture and publickeytoken for an assembly.
What is the compiler of c#?
What is the purpose of constructor in c#?
Can we have static indexer in c#?
Can abstract class have constructor?
Can a class be private in c#?
Why c# is called type safe language?
What does int32 mean in c#?
Why do we need collections in c#?
What is satellite assembly? And steps to create satellite assembly?
What are anonymous functions in c#?
What is the difference between values and reference types?
Why do I get an error (cs1006) when trying to declare a method without specifying a return type?