1 /// <summary> 2 /// 获取config配置文件 3 /// </summary> 4 public class ConfigHelper 5 { 6 private ConfigHelper() 7 { 8 9 } 10 11 /// <summary> 12 /// 根据AppSettings获取配置信息 13 /// </summary> 14 /// <param name="key"></param> 15 /// <returns></returns> 16 public static string GetStringByAppSettings(string key) 17 { 18 string configString = ConfigurationManager.AppSettings[key]; 19 20 return configString; 21 } 22 23 /// <summary> 24 /// 根据ConnectionStrings获取配置信息 25 /// </summary> 26 /// <param name="key"></param> 27 /// <returns></returns> 28 public static string GetstringByConnectionStrings(string key) 29 { 30 string configString = ConfigurationManager.ConnectionStrings[key].ConnectionString; 31 32 return configString; 33 } 34 35 }