What are the differences between const and readonly keywords ?

 Posted by Bharathi Cherukuri on 6/5/2012 | Category: ASP.NET Interview questions | Views: 2653 | Points: 40

The major differences between both the keywords are listed below:

-cannot be static
-value is evaluated at compile time
-initialized at compile time only

-can't be either instance level or static
-value is evaluated at compile time
-can be initialized in declaration or by code in the constructor

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Posted by: Majith on: 6/6/2012 | Points: 10
Read Only :

Read Only is Runtime Constant


Const is Compile time Constant

Login to post response