常数(const )和只读(readonly)

相似:相对于变量,其值基本不变
区别:
常数(const ):其值为硬编码,其值只能在申明时赋值,在类中使用const申明时,const好像隐式静态变量,每个实例不需要保存副本
只读(readonly):其值可以赋值,但只能在构造函数中赋值或申明时指定,申明为readonly的变量,每个类实例中可以有不同的副本

//以上均为个人理解,如有不同或错误请见量,以上在《C#高级编程》中有介绍,下载见
http://bbs.wrclub.net/down/Cshappdf.rar

相关文章:

  • 2022-12-23
  • 2021-12-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-05
  • 2022-12-23
  • 2021-10-30
猜你喜欢
  • 2021-10-25
  • 2021-10-07
  • 2021-10-04
  • 2021-08-18
  • 2022-12-23
  • 2022-01-16
  • 2021-07-26
相关资源
相似解决方案