大学IT网 - 最懂大学生的IT学习网站! QQ资料交流群:367606806
当前位置:大学IT网 > C#技巧 > AppSetting用法实例讲解

AppSetting用法实例讲解

关键词:AppSetting用法实例  阅读(823) 赞(14)

[摘要]本文是对AppSetting用法的讲解,对学习C#编程技术有所帮助,与大家分享。
<configuration>

  <startup>

    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />

  </startup>

  <appSettings>

    <add key="bakName" value="WMSBAK"/>

    <add key="copyName" value="PRELL"/>

  </appSettings>

  <connectionStrings>

    <add name="Default" connectionString="Data Source=.;Initial Catalog=PRELL;Persist Security Info=True;User ID=sa;Password=123456;Pooling=true;Max Pool Size=100000;Min Pool Size=0;Connection Lifetime=3000;packet size=32767;Connection Reset=false" providerName="System.Data.SqlClient"/>

  </connectionStrings>

</configuration>

获取方法

namespace WMSBAK

{

    public class WMSBackUp

    {

        private string BakDBName

        {

            get { return System.Configuration.ConfigurationManager.AppSettings["bakName"]; }

        }

        private string CopyDBName

        {

            get { return System.Configuration.ConfigurationManager.AppSettings["copyDBName"]; }

        }

    }

}


相关评论