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

Value Type and Reference Type Data type in C#?

712


Is c# good for games?

649


What is unmannaged code and will CLR handle this kind of code or not .

780


What is console programming language?

688


What are types in c#?

671


What do you mean by abstract class in c#?

734


What is enumerable in c#?

669


Explain get and set accessor properties?

664


What is a linq in c#?

648


Explain the working of serialization?

662


Is array passed by reference in c#?

722


Why array is faster than arraylist in c#?

682


What is lazy keyword in c#?

671


Explain acid rule of thumb for transactions in c#.

703


What are the problem with .NET generics?

735