const 与 readonly
摘要:
C#箴言:定义常量的两种方法 文章录入:7747.Net 责任编辑:7747.Net 更新时间:2006-9-21 10:38:14 9 【字体:小 大】在C#中定义常量的方式有两种,一种叫做静态常量(Compile-time constant),另一种叫做动态常量(Runtime constant)。前者用“const”来定义,后者用“readonly”来定义。 对于静态常量(Compile-time constant),它的书写方式如下: public const int MAX_VALUE = 10; 为什么称它为静态常量呢,因为如上声明可以按照如下理解(注意:如下书写是错误的,会出编译 阅读全文
posted @ 2011-06-15 13:41 小飞鱼quaq 阅读(114) 评论(0) 推荐(0)
浙公网安备 33010602011771号