Home > DeveloperSection > Interviews > What are the difference between const and readonly?

Posted on    January-25-2014 12:13 AM

 C# C# 
 1 Answer(s)
  1202  View(s)
Rate this:

Sumit Kesarwani

Total Post:782

Posted on    January-25-2014 1:00 AM

A const can not be static, while readonly can be static.

A const need to be declared and initialized at declaration only, while a readonly can be initialized at declaration or by the code in the constructor.

A const’s value is evaluated at design time, while a readonly’s value is evaluated at runtime.

Don't want to miss updates? Please click the below button!

Follow MindStick