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 is the difference between throw and throw ex?
What is final keyword in c#?
What is multithreading with .net?
Is string immutable in c#?
What is orm in c#?
What is use of console?
What is difference between const and static in c#?
What is a linq in c#?
What is an indexer in c#?
What is a service layer c#?
Explain the difference between proc. Sent by val and by sub?
What is difference between gridview and form view?
What are collection classes?
Explain the use of virtual, sealed, override, and abstract method?
Explain about accessibility modifier 'protected internal'?