您的位置:首页 > 移动开发

得到AppSettings中的配置信息的自定义类

2005-12-11 20:48 405 查看
using System;
using System.Configuration;
namespace OpenHack4
{
/// <summary>
/// web.config操作类
/// </summary>
public sealed class ConfigHelper
{
/// <summary>
/// 得到AppSettings中的配置字符串信息
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public static string GetConfig(string key)
{
return ConfigurationSettings.AppSettings[key];
}

/// <summary>
/// 得到AppSettings中的配置bool值信息
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public static bool GetConfigBool(string key)
{
bool result = false;
string cfgVal = GetConfig(key);
if(null != cfgVal && string.Empty != cfgVal)
{
try
{
result = bool.Parse(cfgVal);
}
catch(FormatException)
{
// Ignore format exceptions.
}
}
return result;
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: