If I want to define a set of global strings in my C# program, I’ve been using settings so that I access them with
... Properties.Settings.Default.StringA ...
... Properties.Settings.Default.StringB ...
etc.
I was reading some SO questions that landed me with the idea I should create a static class
public static class Marker
{
public static readonly string StringA = "my text A";
public static readonly string StringB = "my_other_text";
}
of course, accessing these would be simple with
Marker.StringA
While I’m developing my hadbits, which method should I use for what constants or is this a personal style choice?
Thanks.
Use the resource manager for access to culture-specific resources at run time. Etc text displayed on UI.
Use the App.Config or Web.Config for environment based constants. Here is a good example from Skeet https://stackoverflow.com/a/1431754/208565
Use constants and readonly fields for code level usage.