Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Configuration;
- namespace Configuration
- {
- public static class SiteConfigurationReader
- {
- public static String appKeyString //for string type value
- {
- get
- {
- return ConfigurationManager.AppSettings.Get("appKeyString");
- }
- }
- public static Int32 appKeyInt //to get integer value
- {
- get
- {
- return ConfigurationManager.AppSettings.Get("appKeyInt").ToInteger(true);
- }
- }
- // you can also get the app setting by passing the key
- public static Int32 GetAppSettingsInteger(string keyName)
- {
- try
- {
- return Convert.ToInt32(ConfigurationManager.AppSettings.Get(keyName));
- }
- catch
- {
- return 0;
- }
- }
- }
- }
- <configuration>
- <configSections>
- <!-- some stuff omitted here -->
- </configSections>
- <appSettings>
- <add key="appKeyString" value="abc" />
- <add key="appKeyInt" value="123" />
- </appSettings>
- </configuration>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement