天使半只翼

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
<configuration>
    <configSections>
        <sectionGroup name="" type="">    </sectionGroup>
        </sectionGroup>
        
        <!--自定义配直web.config参数-->
        <section name="mySection" type="System.Configuration.SingleTagSectionHandler" />
        <!--自定义配直web.config参数-->
        
    </configSections>
    
    <!--自定义配直web.config参数-->
    <mySection section1 ="one" section2="two" section3="three" section4="four" />
    <!--自定义配直web.config参数-->
    
    <appSettings>
        <add key="" value="" />
    </appSettings>

    <connectionStrings/>
</configuration>

 

 

using System;
using System.Collections;
using System.Configuration;

public class ReaderConfiguration
{
    /// <summary>
    /// 读取web.config中自定义参数值
    /// </summary>
    /// <returns>String</returns>
    public String ReadMySettings()
    {
        IDictionary mySettings = (IDictionary)ConfigurationSettings.GetConfig("mySetting");
        string section1 = (string)sampleTable["section1"];
        string section2 = (string)sampleTable["section2"];
        string section3 = (string)sampleTable["section3"];
        string section4 = (string)sampleTable["section4"];
        return section1 + "," + section2 + "," + section3 + "," + section4 ;
    }
}

 

posted on 2013-03-11 16:07  天使半只翼  阅读(1989)  评论(0编辑  收藏  举报