Adding and reading from a Config file

后端 未结 3 1393
执念已碎
执念已碎 2020-12-04 10:40

I have created a C# console based project. In that project i have some variables like companyName, companyType which are Strings.

3条回答
  •  攒了一身酷
    2020-12-04 11:13

    1. Add an Application Configuration File item to your project (Right -Click Project > Add item). This will create a file called app.config in your project.

    2. Edit the file by adding entries like within the tag.

    3. Add a reference to the System.Configuration dll, and reference the items in the config using code like ConfigurationManager.AppSettings["keyname"].

提交回复
热议问题