C#中ConnectionStrings和AppSettings的区别及取值

connectionStrings主要设置连接字符串

<connectionStrings>
<add name="ConnectionName" connectionString="XXXXXXX”/>
</connectionStrings>

AppSettings感觉相当于公用的字典

 <appSettings>
 <add key="Url" value="http://192.1.1.1:8080/XXXXX" />
 </appSettings>

取值

   var connectionName=ConfigurationManager.ConnectionStrings["ConnectionName"].ToString();
   var url = ConfigurationManager.AppSettings["Url"];
   

你可能感兴趣的:(.NET,c#)