What is the Difference between read only and constant
variables?

Answer Posted / vijay bhaskar semwal

some more difference
Unlike const, when using readonly, the value is set when
the instance is created. This means that you can specify
the value of the readonly in the constructor of your class.

Another difference between const and readonly, is that
const are static by default, where with readonly, you must
define it as static (if you want it to be).

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain About CLS?

541


What is a c# delegate?

601


What is the default modifier for class in c#?

509


Explain About sn.exe

498


What is the difference between int.parse and int.tryparse methods?

564






What is generic in c#?

453


What does async mean in c#?

501


What is the difference between string keyword and system.string class?

513


Give an example of a directcast.

512


What is the difference between dictionary and hashtable in c#?

464


What are the commonly used i/o classes?

528


What is difference between dictionary and hashtable?

515


What is the difference between overriding and overloading in systemverilog?

452


What is ac callback?

498


Why to use lock statement in c#?

490