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

What is the use of ienumerable in c#?

553


What is class method c#?

483


What is type system in c#?

522


What you mean by inner exception in c#?

531


What is a service layer c#?

471






Is as keyword in c#?

522


Explain how do you directly call a native function exported from a dll?

510


What is sqlconnection in c#?

502


What is the difference between IEnumerator and IEnumerable?

681


What are the advantages of using c#?

513


How do I open the console?

609


Explain the differences between static, void and public in c#?

529


How long does a loop recorder procedure take?

521


What is the correct way of declaring an xml namespace?

472


How does one compare strings in c#?

546