A quick synopsis on the differences between 'const' and 'readonly' in C#:
' const':- Can't be static.
- Value is evaluated at compile time.
- Initiailized at declaration only.
- Can be either instance-level or static.
- Value is evaluated at run time.
- Can be initialized in declaration or by code in the constructor.
http://weblogs.asp.net/psteele/archive/2004/01/27/63416.aspx
C#中const与readonly的区别
本文概述了C#中const与readonly关键字的主要区别:const只能在声明时初始化且值在编译时确定,不能是静态成员;而readonly可以在声明时初始化也可以在构造函数中初始化,可以是实例级或静态成员。
740

被折叠的 条评论
为什么被折叠?



