What is the difference between readonly and const

Answer Posted / chandan kumar

The read only keyword is different from the const keyword. A
const field can only be initialized at the declaration of
the field. A read only field can be initialized either at
the declaration or in a constructor. Therefore, read only
fields can have different values depending on the
constructor used. Also, while a const field is a
compile-time constant, the read only field can be used for
runtime constants as in the

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is difference between string and stringbuffer in c#?

474


what is the difference between a struct and a class in c#?

569


Is php easier than c#?

497


Which string method is used for concatenation of two strings in c#?

475


What is oledb in c#?

505






Explain how can I get around scope problems in a try/catch?

488


What is transparent caching with aop ?

624


How do I create a multi language, multi file assembly?

624


What does it mean?

559


What is the use of delegates in c#?

480


How we convert private assembly into public assembly?

524


Why is it efficient to use System.string under System.Text.StringBuilder ?

525


Explain the difference between abstract class and interface.

600


Can structs in c# have destructors?

549


What is the use of 'using' statement in c#?

487