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 the relation between classes and objects?

526


How can I get around scope problems in a try/catch?

477


Can abstract class have private constructor c#?

510


What is difference between var dynamic and object in c#?

516


Why do we use reflection in c#?

487






What are the different approaches of passing parameters to a method?

482


What is anonymous types in c#?

502


Difference between StackPanel and RelativePanel ?

575


What is the difference between list and arraylist c#?

522


What is datatable and dataset in c#?

487


What is singleordefault?

515


Where do we use serialization in c#?

496


Is array thread safe c#?

482


What will be the output of the following code?

509


Is it possible to have a static indexer in c#?

546