Posted by wayne on Jan 03 2005 in Agile
.NET Constants are Really Constant
From Haacked How Constant Are Your Constants in .NET
When one assembly references a constant in another assembly, the compiler will embed the value of that constant into the assembly.
This could really lead to some hard to find bugs. Imagine deploying just the library with the changed constant, and none of you applications that depend on the constant changing their behavior!
... it would be better to make this a public static read only variable...
Haaked's recommendation is a good work-around for those "constants" that might need to be changed during the lifetime of the application.
This reminds me of my previous post on Public Variables In VB.NET Modules in that the compiler does unexpected things to your code.
This entry was posted by wayne and filed under Agile.