What is the Difference between read only and constant
variables?

Answer Posted / kishore maddineni

all above answers are correct.But there is another point.

readonly variable can be assigned at declaration or at run
time which is must be in constructor. Readonly value can't
be modified.

Constant variable must be assigned at the time of
declaration only ,which is can't be modified.

Is This Answer Correct ?    36 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is dll hell, and how does .net solve it?

718


Why we need get set property in c#?

721


What are the types of assembly available

707


How does it work?

677


what is IFormatable

769


How do I link two windows forms in c#?

652


What are the 3 elements of delegation?

714


Can we override interface method?

732


If I have more than one version of one assemblies, then how'll I use old version (how/where to specify version number?)in my application?

702


What is a clr host?

725


What is the advantage of constructor in c#?

685


What are logical operators in c#?

703


Are all methods virtual in c#?

716


What is the purpose of static?

714


Can a string be null c#?

669