I am creating a search class, so a constant value will be used in all projects. The fact is that there are several solutions for creating such a thing. I could create one class with enumerations, structures or constants in it, or create one class for each “object”. I am wondering what would be the best solution.
At first I thought of doing something like this:
public static class Defines
{
public enum PAGELAYOUT_NAMES
{
STANDARD = "Standard"
}
}
But personally, I do not like to use strings in enumerations. Another option would be to use a structure that is even uglier if you see the code:
public static class Defines
{
public struct PAGELAYOUT_NAMES
{
public static string STANDAARD = "Standaard";
}
}
This looks a little better, but can be confusing if you have a lot of options:
public static class Defines
{
public const string PAGELAYOUT_NAMES_STANDARD = "Standard";
}
When typing this post, I think it will be the best / clean option:
public static class PageLayout
{
public const string STANDARD = "Standard";
}
?
, , .
Edit
, . , Int, DateTime . , , .
:
internal class Base<T>
{
internal T Value{ get; private set;}
internal Base(T value)
{
Value = value;
}
}
public class PageLayout
{
public static string Standard { get { return new Base<string>("Standard").Value; } }
}
, .
, , , .