May 15, 2006
–相同
const和readonly的值一旦初始化则都不再可以改写.
–不同
const只能在声明时初始化;readonly既可以在声明时初始化也可以在构造器中初始化;
const隐含static,不可以再写static const;readonly则不默认static,如需要可以写static readonly;
const是编译期静态解析的常量(因此其表达式必须在编译时就可以求值);readonly则是运行期动态解析的常量;
const既可用来修饰类中的成员,也可修饰函数体内的局部变量;readonly只可以用于修饰类中的成员
The URI to TrackBack this entry is: http://recordsome.blogsome.com/2006/05/15/p26/trackback/
No comments yet.
RSS feed for comments on this post.
Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>