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

How to implement delegates in c#.net

548


Explain About CLS?

545


What is a .aspx file?

460


What is console writeline in c#?

470


What are interfaces in c#?

517






When To use HashTable In C#

549


Can c# inherit multiple classes?

515


What is a cshtml file?

534


Explain manifest & metadata in c#.

534


How to implement an object pool in c#.net.

548


Is c# front end or back end?

511


Define multicast delegate in c#?

514


How string definitions will prevent escaping on backslashes in C#?

524


What are the collection types can be used in c#?

469


Is it possible to have different access modifiers on the get/set methods of a property in c#?

600