I have a Property named A
and it was set to the value AAA
via the Properties Setting Window in Visual Studio (Project → Properties → Settings).
I can obtain the original value for the property A
using this loop.
If I change the value, to say NewValue
, I can get the new value using the code:
Properties.Settings.Default.A
However, within the loop, I don't know how to get the current property value without using the syntax:
Properties.Settings.Default.VariableName
for example:
Properties.Settings.Default.A= "NewValue";
Properties.Settings.Default.Save();
foreach (SettingsProperty _currentProperty in Properties.Settings.Default.Properties)
{
Console.WriteLine(_currentProperty.Name + "," + _currentProperty.DefaultValue.ToString());
}
The above loop shows the original value of the property (old default value which was AAA
).
I have checked the user.config
file and made sure it is showing NewValue
.
I assume that there must be some way to refer to the current value using a property or a method I don't know (maybe I should iterate another collection?).
The question is, how to display this new value inside the foreach
loop above?