I have a class that looks something like this:
public class Constants
{
private static readonly Lazy<Constants> lazy =
new Lazy<Constants>(() => new Constants());
public static Constants Instance { get { return lazy.Value; } }
Dictionary<string, List<string>> validApplicationTypes;
public Dictionary<string, List<string>> ValidApplicationTypes
{
get { return validApplicationTypes; }
}
private Constants()
{
// validApplicationTypes is populated from a DB table
}
}
Now outside I access the valid application types like this:
Constants.Instance.ValidApplicationTypes
What would be the best way to add a bunch of string constants to this class? should I add them like:
private static readonly string message= "SomeMessage";
public static string Message
{
get { return message; }
}
and access them like: Constants.Message
or should I add them like this:
private string message= "SomeMessage";
public string Message
{
get { return message; }
}
and access them like: Constants.Instance.Message
Is there any difference between these 2 ways of creating them inside the singleton and accessing them from the outside?