C#.NET WebConfig操作

 

  
    
using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;

namespace Pub.Class
{
/// <summary>
/// Web.Config配置类
/// </summary>
public class WebConfig
{
public static readonly string DoMain = WebConfig.GetApp( " DoMain " );

#region GetApp
/// <summary>
/// 取appSettings结点数据
/// </summary>
/// <param name="key"> key </param>
/// <returns> 返回值 </returns>
public static string GetApp( string key)
{
if (ConfigurationManager.AppSettings[key] != null )
return ConfigurationManager.AppSettings[key].ToString();
return null ;
}
#endregion

#region GetConn
/// <summary>
/// 取connectionStrings结点数据
/// </summary>
/// <param name="key"> name </param>
/// <returns> 返回值 </returns>
public static string GetConn( string key)
{
if (ConfigurationManager.ConnectionStrings[key] != null )
return ConfigurationManager.ConnectionStrings[key].ToString();
return null ;
}
#endregion
}
}

 

你可能感兴趣的:(config)