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.

Confusing?

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

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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