Differance between Const and Readonly
Const
1) Value evaluated at compile time
2) can't be static.
3) Initialize at declaration only.
e.g. const int a = 100
Readonly
1) Value evaluated at runtime.
2) Can be static.
3) can initialize at declaration or in constructor.
e.g. public readonly int doc = 5;
public program()
{ doc = 5; }
I have never implemented Const or Readonly. What is their extra ordinary purpose?
ReplyDelete