Get dynamic property from Settings

.net, app-config, c#, settings

Solution

String propertyValue = MySettings.GetType()
.GetProperty("NAME_OF_THAT_THING")
.GetValue(MySettings, null); //replace MySettings with null in GetValue(...) if MySettings is  a static class

Problem

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_OF_THAT_THING is no problem, but what if the name is variable? I tried: ``` String propertyValue = MySettings.GetType().GetProperty("NAME_OF_THAT_THING").ToString(); ``` But the only thing I got back is the name of the property. How can I do this?

Original source