reading from app.config file

后端 未结 8 2425
不知归路
不知归路 2020-11-29 19:34

I am trying to read StartingMonthColumn and CategoryHeadingColumn from the below app.config file using the code

ConfigurationSettings.AppSettings[\"StartingM         


        
8条回答
  •  误落风尘
    2020-11-29 20:21

    This:

    Console.WriteLine( "StartingMonthColumn is {0}", ConfigurationManager.AppSettings["StartingMonthColumn"]);
    

    works fine for me.

    Note that ConfigurationManager is in the System.Configuration namespace (so you'll likely want a using System.Configuration; statement), and that since what you read in has a string type you'll need to parse what you read in to use it as a number.

    Also, be sure you set system.configuration.dll as a reference in your project or build script.

提交回复
热议问题