zoukankan      html  css  js  c++  java
  • using App.cofig to Store value

    As we know, In asp.net ,we can use web.config to store the configuration for the website.but In WinForm, we can use App.config to function the same function. See below settings:

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
    <appSettings>
    <add key="test" value="testwwwwwwwwww"/>
    </appSettings>
    </configuration>

    We can use the following code to control the value:

    using System;
    using System.Windows.Forms;
    using System.Configuration;

    namespace WindowsFormsApplication6
    {
    public partial class Form1 : Form
    {
    public Form1()
    {
    InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
    string value = ConfigurationSettings.AppSettings["test"];
    MessageBox.Show(value);
    }
    }
    }

    Can you see, It's just so easy. so if you want to config the SQL server by configuration chars, you can put your connection strings here , and use the ConfigurationSettings.Appsettings[] method to read it.

  • 相关阅读:
    My SQL
    弹窗
    DBDA
    ThinkPHP验证码与文件上传
    ThinkPHP表单验证
    ThinkPHP增删改
    ThinkPHP模型(查询)
    ThinkPHP跨控制器调用方法
    Superset安装
    Presto资源组配置
  • 原文地址:https://www.cnblogs.com/scy251147/p/2163561.html
Copyright © 2011-2022 走看看