| Constant(const) | Readonly |
| Constants are immutable values and do not change their value for the life of the program. Constants are known as the compile time. |
ReadOnly is also an immutable value and does not change its value for the life of the program. ReadOnly is known as the runtime. |
| Assigned a value at the time of declaration. Ex
|
Assigned a value either at the run time or inside a constructor (instance initialization). Ex
|
| Constant cannot be static i.e. you cannot declare constant as static. Ex
|
Readonly can be static i.e. you can declare readonly as static. Ex
|
| Constant value can access with the class name. Ex
|
Readonly value can access by instance of the class. Ex
|
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment
It is the same account you read, post and publish with — and you will come straight back to this page.

Subhashkumar YadavPosted Dec 16, 2016, 5:49 AM
Nicely explained...............
sushil kumarPosted Dec 8, 2016, 12:24 PM
Thank you .....Upendra Pratap Shahi
Upendra Pratap ShahiPosted Dec 8, 2016, 10:33 AM
Nice one explaination regarding this...
Jaco ZwartsPosted Dec 7, 2016, 1:30 AM
Sushil,Thanks for posting
Mohamed KacemPosted Dec 1, 2016, 12:05 PM
It's a good analyse. thanks
Sreekanth ReddyPosted Dec 1, 2016, 5:13 AM
It's very clear. Thanks for posting.