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 between read only and constant
variables?

Answer Posted / bharathi

Constants:
constant is used for declaring variable as constant and this constant value cannot be modified once after declartration.

It is must to declare the constant value at the time of declaration only.
Example:
constant int y=5;

Readonly

Readonly variables can not be modified like constant,but it is after initialization.
So.it is not mandatory to initialize those variables at declaration time.they can also be initialize after declaration.

Example:
readonly int x;

add()
{
x=5;
}


Both after initilization, we can not modify those values again.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is arraylist thread safe?

871


Explain get and set accessor properties?

883


Is concurrent queue thread safe?

895


Define delegate in c#?

916


What is the difference between struct and class c#?

988


Is it possible to have different access modifiers on the get/set methods of a property in c#?

979


What is binding in c#?

902


What are boxing and unboxing?

910


What is view model in c#?

845


What are the types of access modifiers?

912


How do I use the 'using' keyword with multiple objects?

951


What is base class in c#?

999


What's different between c# and c/c++?

936


What is the purpose of escape sequence?

1012


How can you read 3rd line from a text file?

992