I've got a Visual Studio project that contains a few StringCollections under app settings. I want to iterate over these properties/settings at runtime but can't find a way to do so. I've tried this:
foreach (SettingsProperty prop in Properties.Settings.Default.Properties)
string className = (prop.DefaultValue as StringCollection)[1];
But prop.DefaultValue
is not a StringCollection
and returns null. I realize I can use Properties.Settings.Default["SettingName"]
but that requires me to know the setting name beforehand. There has to be a way to iterate through the application setting names and read their associated StringCollection
values, but how? I can't find an example after hours of searching.
How about using
if(Properties.Settings.Default[prop.Name] is StringCollection sc){
...
}
in your loop?