Normally, when we want to declare a constant that is not updateable through out the application by doing the following:
public const int MAX_DAYS = 30;
In case, your application would like to allow the system administrator changing the MAX_DAYS value to accommodate their business environment, you need a way to do it. This can be done by replacing the "const" keyword with "readonly":
public class MyConstants
(
public readonly int MAX_DAYS;
public MyConstants()
{
MAX_DAYS = {read the value from database OR config file};
}
)
No comments:
Post a Comment