Sky 的专栏

我们使用的是有形的东西,实质是无形的东西在起作用.

C# app.config read values

请注意引用using System.Configuration;

using System;
using System.Data;
using System.Net;
using System.Windows.Forms;
using System.Configuration;

namespace TY.Kanban.Prod
{
    public partial class Kanban_Prod_A : Form
    {
        public Kanban_Prod_A()
        {
        }

        private void Kanban_Prod_A_Load(object sender, EventArgs e)
        {
              }

        private void GetConnectionStrings()
        {
            string str = System.Configuration.ConfigurationManager.AppSettings.GetValues("pw")[0];
            this.Text = str;
        }

        static void DisplayAppSettings()
        {

            try
            {

                AppSettingsReader reader = new AppSettingsReader();


                NameValueCollection appSettings = ConfigurationManager.AppSettings;

                for (int i = 0; i < appSettings.Count; i++)
                {
                    Console.WriteLine("Key : {0} Value: {1}",
                      appSettings.GetKey(i), appSettings[i]);
                }

            }
            catch (ConfigurationErrorsException e)
            {
                Console.WriteLine("[DisplayAppSettings: {0}]", e.ToString());
            }

        }

}
}

阅读更多
文章标签: c# object string class
个人分类: CODE_C#
上一篇MSSQL SQL获取所有数据库名、表名、储存过程以及参数列表
下一篇探讨下Tag标签的数据库设计(千万级数据量)
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭