Get dynamic property from Settings

前端 未结 4 956
闹比i
闹比i 2021-01-04 21:01

I\'ve got a few properties stored in my AppConfig and now I want to access them dynamically (e.g. in a loop or function).

Accessing the values using MySettings.NAME_

4条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-04 21:55

    Have you tried using the ConfigurationManager.AppSettings property? You should be able to get your setting via the following code:

    String propertyValue = ConfigurationManager.AppSettings["NAME_OF_THAT_THING"];
    

    The MSDN article for ConfigurationManager.AppSettings also includes an example for looping through all of the entries in AppSettings by index, rather than name.

提交回复
热议问题