Because when constants are publicly exposed (instead of internal), the danger exists that when an outside assembly references them, it may become "out of date" when the assembly that declares them is updated with new constant values, but the referencing assembly is not re-compiled.
Say, for example, the referenced assembly containing the "updated" constant values forms part of a "plugin" architecture, where a new version of the plugin could simply be "dropped" into the referencing application's folder without recompiling and redeploying the application. Even if the application that referenced a constant from the "plugin" assembly that originally declared it, the application will not use the new updated values, and will continue using the old ones instead.
This happens because when the compiler sees a constant, it "inlines" its value into the expressions or statements that contain ("reference") it, wherever that may be.
To solve this problem, and you really want to expose a "constant" to the outside world, rather declare the symbol as public static readonly
. That way, if the value is ever updated, any outside assemblies that reference it will automatically use the update value(s), even without needing a recompile.
But if you really want to use const
instead, make sure it is really a constant that will never change, i.e. laws of nature, physical constants, like Pi.