编译时
class Test { const int A = B * 10; const int B = 10; public static void Main(string[] args) { Console.WriteLine("A is {0},B is {1} ", A, B); Console.Read(); } }
运行时
必须从上到下,一步一步运行
class Test { static readonly int A = B * 10; static readonly int B = 10; public static void Main(string[] args) { Console.WriteLine("A is {0},B is {1} ", A, B); Console.Read(); } }
new要到运行时才能执行。
readonly在构造函数的时候还可以赋值,const就不可以。
http://www.cnblogs.com/royenhome/archive/2010/05/22/1741592.html