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

Why should you override the tostring() method?

1050


Difference between type constructor and instance constructor? What is static constructor, when it will be fired? And what is its use?

1053


Is c# the same as d flat?

917


How do you specify a custom attribute for the entire assembly (rather than for a class)?

956


Explain About stateless and state full web service

994


How to add a readonly property in c#.net

938


What is hashtable in c# net with example?

937


Enlist the different types of classes in c#?

929


Are c# constructors the same as c++ constructors?

953


What is collection class c#?

917


What is bitwise operator in c#?

932


How do I create a multilanguage?

922


How to implement singleton design pattern in c#?

893


Write a program to create a user control with name and surname as data members and login as method and also the code to call it. (Hint use event delegates) Practical Example of Passing an Events to delegates

882


Can we make a class private in c#?

941