Single file/class to store constants in ASP.NET
I have a ASP.NET web application which has more than 100 pages. Each page is using some commo开发者_JAVA技巧n values ( ex : current USDoller rate) .This can be changed at any time. Now I want to maintain this value in a single file so that i can change only her at any time to get it reflected throughtout the project.I dont want to store it in web config. I want to store it in some other place
Any thoughts ?
Make a static class like this:
public static class MyConsts {
public const string Prefix = "n-";
}
From anywhere in your project use:
MyConsts.Prefix
(Note: const
is implicitly static)
My initial thoughts are one of the following:
- Store it in a database table and create a mechanism for editing the values
- Create a static class and store them there
Why not just make a static class and store the constants there. That way when you change it, everything will get the new values.
精彩评论