what is the main differnce between const,readonly and static

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why do we need private constructor in c#?

670


What is datasource c#?

664


What does static mean in c sharp?

809


What is the advantage of constructor?

651


Major difference between Basic httpbinding and WShttpbinding?

783


Who introduced c#?

668


What is the use of command builder?

744


What is type keyword in c#?

714


What is the task perform by clr?

765


what is the meaning of Object lifetime in OOPS

740


Why do we use interface in c#?

698


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

714


Does a class need a constructor c#?

688


What are the types of assembly available

714


What is a Managed Code??

744