Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What is the difference b/w constant & read only variable?

Answer Posted / maloy.adhikari

Constants: The value can't be changed

Read-only: The value will be initialized only once from the
constructor of the class.


Const:
1)Can not be static.
2)The value is evaluated at compile time.
3)It is initialized at declaration only.
4)the const keyword is used for compile-time constants

Readonly:
1)Can be either instance-level or static.
2)The value is evaluated at run time.
3)It can be initialized in declaration or by code in the
constructor. Therefore, readonly fields can have different
values depending on the constructor used.
4)the readonly keyword is used for runtime constants.

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is scalar property?

1077


Is dapper better than entity framework?

976


How would you deploy your old applications with .net framework 4.0? Are the old applications compatible?

895


What is Attribute Routing in ASP.Net MVC?

1102


what is ssdl?

1152


What is page life cycle?

1001


Why we need a separate mobile project template, while we can render our web application in mobile ?

1154


Describe the gac in the .net framework.

1022


What are HTML Helpers, AJAX Helpers in ASP.Net MVC?

1047


What is NonActionAttribute ?

1022


Explain the advantage of packaging over xcopy in .net?

979


How we can call a JavaScript function on the change of a Dropdown List in ASP.Net MVC?

1088


How can I tell what .net framework is installed?

977


what is entity framework advantage?

1090


What are sections?

1133