There seem to be three choices for implementing publicly accessible constants in C#. I'm curious if there are any good reasons to choose one over the other or if it's just a matter of personal preference.
Choice 1 - private field plus property getter
private const string _someConstant = "string that will never change";
public string SomeConstant
{
get { return _someConstant; }
}
Choice 2 - property getter only
public string SomeConstant
{
get { return "string that will never change"; }
}
Choice 3 - public field only
public const string SomeConstant = "string that will never change";
Which do you recommend and why?
Update
Apparently, this has turned into a discussion of whether to use const or static readonly. Not exactly what I intended, but it did teach me that Choice 3 is definitely a bad idea because, if the value of the const changes in a future version, it requires all referencing assemblies to be recompiled.
However, I don't think anyone has really discussed Choice 2 yet. I'm still curious if there's any disadvantage with having just a getter that returns a value and nothing else.