How C # reads the config file

Source: Internet
Author: User

The value in the configuration file is obtained by using ConfigurationManager's appsettings["One of the field names to get" method.

<span style="font-size:24px;"> </span><span style="font-size:14px;">Private voidNormalform_load (Objectsender, EventArgs e) {              stringWorkunitname = configurationmanager.appsettings["Workunitname"]. ToString (). Trim ();//Station Use            stringProcedureName = configurationmanager.appsettings["procedurename"]. ToString (). Trim ();//OperationWorkunitno = configurationmanager.appsettings["Workunitno"]. ToString (). Trim ();//Station CodingProcedureno = configurationmanager.appsettings["Procedureno"]. ToString (). Trim ();//Operation CodeTosslaboperater.text ="Operator:"+Operatername; Tosslabstationno.text="Current unit of work:"+Workunitname; Tosslabcurrentprocedure.text="Current Operation:"+procedurename;    Mshowchart (); //number of initial load station statisticsMshowconfig ();//Determine if the Configure button is displayed}</span>

You must refer to the System.Configuration namespace (DLL) when you use the ConfigurationManager object, or you will get an error that cannot be referenced. NET provides the System.Configuration.dll that the classes provided under this namespace can easily read and write these parameter configurations to an XML file.

How C # reads the config file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.