Static Readonly vs Const

There is no such Static Readonly in Java. Somehow, it is a cool concept in C#. The both different in how compiler treat them. If const, during compilation, the value is baked and will never change. Let say program X uses library Y, when Y’s field programVersion is a const, X will absorb the value baked. So, next time we have newer Y, the old value is still used. Different than static readonly where the program will always refer to its value, however, it limits the ability to change as if like in the const.


It is like PI (const) and programVersion (better static readonly).


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s