Prefer readonly to const - Effective C#学习笔记(2)
来源:互联网 发布:js push.apply 编辑:程序博客网 时间:2024/05/28 22:10
尽量使用readonly的原因是它比const更加灵活。
这里作者给我们的建议不再是Always,而是Prefer。这是因为readonlyt的性能是比const稍低的。作者的原话是slight slowly。这是因为readonly声明的是 run-time常量,而const定义的则是complile-time常量。
readonly更灵活表现在:
1,不必总是static的。因为const是static的
2,可以附表达式,erconst则只能是常量
为了更加灵活的程序,一点点的性能损失是值得的!
- Prefer readonly to const - Effective C#学习笔记(2)
- Effective C# 2:Prefer readonly to const
- Prefer the is or as Operators to Casts - Effective C#学习笔记(3)
- effective c++ 学习新得之 条款2 prefer const,enum, inline to #defines
- Effective C++(Item1) Prefer const and inline to #define
- Effective C#读书笔记(2)Readonly优于Const
- Effective C#阅读笔记-2.使用readonly而不是const变量
- Effective C++,rule 2,Prefer const,enum and inlines to #define
- Effective C#阅读笔记-8Prefer Variable Initializers to Assignment Statements
- 《C#入门到精通》学习笔记 -- const 与 readonly
- Effective C#之12:Prefer Variable Initializers to Assignment Statements
- Effective C#之24:Prefer Declarative to Imperative Programming
- Effective C#之Item 35:Prefer Overrides to Event Handlers
- Effective C#之Item 41:Prefer DataSets to Custom Structures
- CLR Via C# 学习笔记(3) 常量和字段(const readonly)
- Effective C++ 20. Prefer pass-by-reference-to-const to pass-by-value
- Effective C# 原则2:为你的常量选择readonly而不是const(译)
- Effective C# 原则2:为你的常量选择readonly而不是const
- AF_INET 和PF_INET区别;AF_LOCAL PF_LOCAL 区别.
- 路易斯·郭士纳
- 孙子说--摘录
- Coding的常见问题
- 微软研发智能系统 可通过电脑24小时监控员工
- Prefer readonly to const - Effective C#学习笔记(2)
- 越来越多中国企业准备大幅提高工资
- Windows Mobile 应用开发比较经典的几个网站与博客
- Google不为人知的九个秘密:员工宝宝也有福利
- Windows Mobile 开发工具和资源
- VC6的一个bug???
- 职业生涯规划八条原则
- 最新高薪风向标:2008职场“钱”途六大指南
- AJAX.NET的简单示例