How to handle multiple global constants in an application
Posted on: October 22, 2012
The best way to have something organized and having constants in a single place is to have a class that will have inner class. This way, you can organize by theme your constants.
1public static class GlobalConstants {2 public static class Division1 {3 public const string Const1 = "123";4 public const string Const2 = "qwe";5 public const string Const3 = "asdfgh";6 }78 public static class Division2 {9 public const string Const1 = "123";10 }11}
Of course, it's always better to have your constant in the class that they are more related. For example, the default value for a specific property of a class should be directly inside this class. But, for global constants that are used across the application, than having a global constants class can do the job.