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 main differnce between const,readonly and static

Answers were Sorted based on User's Feedback



what is the main differnce between const,readonly and static..

Answer / komilla shaheen

const is the keyword where we can intialize the variable
with some value which is constant throughout the program it
cannot be changed.
static is the keyword which is intialized at complile time
and had to change at compile time only.
readonly is for the varible which is readonly cant be
changed.

Is This Answer Correct ?    9 Yes 1 No

what is the main differnce between const,readonly and static..

Answer / vijay rana

const is used to create a constant value which will be
constant throuout the class

static is used for a commaon variable for all objects, it is
not part of a object, it is a part of class, every object
will share this value,
read,

there are many situation in which we want to intialize the
value of a constat variabl at run time, in which we can have
different values for different objects, with the help of
readonly we can define the value of any object at runtime
which will not be changed later

Is This Answer Correct ?    6 Yes 0 No

what is the main differnce between const,readonly and static..

Answer / raja

1. we can initialize constant variable only at the
declaration where as readonly varaiable can be initialized
at either declaration or in constructor.

2. we can't use static modifier for the const variable
where as readonly variable can be declared as static

Is This Answer Correct ?    5 Yes 0 No

Post New Answer

More C Sharp Interview Questions

Are tuples mutable c#?

0 Answers  


What are c# i/o classes? What are the commonly used i/o classes?

0 Answers  


What is thread pooling?

0 Answers  


If you define a user defined data type by using the struct keyword, is it a value type or reference type?

0 Answers  


Explain the difference between the system.array.copyto() and system.array.clone()?

0 Answers  


Can you prevent your class from being inherited and becoming a base class for some other classes?

5 Answers  


What is the difference between early binding and late binding in c#?

0 Answers  


What?s the C# equivalent of C++ catch (?), which was a catch-all statement for any possible exception?

1 Answers   Visual Soft,


What is difference between private, protected, and public in C#?

0 Answers   B-Ways TecnoSoft,


What are Regex / regular expressions ?

0 Answers   QuestPond,


What is a cs file?

0 Answers  


Why do we need abstract class?

0 Answers  


Categories