views:

75

answers:

1

Hi guys

I am trying how figure how to setup like for instance

Color.RGG.Black which equal to "#000000"

I am trying to make it similar like that and implement into my Constants Class. How do I do this?

Constants.Page.Title.MyCase equal to "My Case";

Thanks

+5  A: 

You can set that up by using nested static classes:

public static class Constants
{
    public static class Page
    {
        public static class Title
        {
            public const string MyCase = "MyCase";
        }
    }
}
Fredrik Mörk
You could also use Namespaces instead of nesting classes, it's probably a more elegant solution.
Kane
Although the original poster said they wanted it within their 'Constants' class, though that may have been just because they didn't realise namespaces could be used.
Jamie Love
@Kane: yes this could also be achieved with namespaces. That may be the more elegant way, unless you also want constants defined on "intermediate" levels (such as `Constants.SomeValue` or `Constants.Page.SomeOtherValue`).
Fredrik Mörk