我已经阅读了各地const和static readonly各个领域.我们有一些只包含常量值的类.用于我们系统中的各种事物.所以我想知道我的观察结果是否正确:
const
static readonly
这些常量值是否应始终static readonly适用于所有公开的内容?并且仅const用于内部/受保护/私有值?
您有什么推荐的吗?我是否可能甚至不使用static readonly字段,而是使用属性?
c# constants
是什么区别const,并readonly和你使用一个比其他?
readonly
.net c# const constants readonly
c# ×2
constants ×2
.net ×1
const ×1
readonly ×1