I’ve read around about const and static readonly fields. We have some classes which contain only constant values. They are used for various things around in our system. So I am wondering if my observation is correct:
Should these kind of constant values always be static readonly for everything that is public? And only use const for internal/protected/private values?
What do you recommend? Should I maybe even not use static readonly fields, but rather use properties maybe?
public static readonlyfields are a little unusual;public staticproperties (with only aget) would be more common (perhaps backed by aprivate static readonlyfield).constvalues are burned directly into the call-site; this is double edged:If the value will never change, then const is fine –
Zeroetc make reasonable consts ;p Other than that,staticproperties are more common.