readonly simply stop the value held by the variable, which will be changed after initialization. This does not affect the static lifetime - it is still the same as before.
Note that if static is a reference, the readonly attribute does not stop changing the underlying object, it only stops changing the value of the static variable โ in the case of a class reference, that the Value is the link itself.
C # MSDN docs on readonly:
http://msdn.microsoft.com/en-us/library/acdd6hb7(v=VS.100).aspx
A readonly static will have a similar effect on const (assuming you are making static isible for const ) when you talk about having a global immutable value. When you first try to access the statics, it will be initialized in place and will never be changed.
So:
public static readonly string Something = "what";
Will behave like:
public const string Something = "what";
Although the latter is a compile-time constant, the former is not - therefore, the behavior has some key differences. I talked more about the idea of โโvalue, accessible throughout the world, which does not change.
In terms of ASP.NET and static utilization, the difference between static readtly and const is that static simply takes an initialization charge if it has not already been initialized. However, const better suited to describe usage.
source share