title: C# How to loop through Properties.Settings.Default.Properties changing the values
body: <p>I have the following code:</p>
  
  <pre><code>foreach (SettingsProperty currentProperty in Properties.Settings.Default.Properties)
  {
      if (Double.TryParse(GenerateValue()), out result))
      {
          currentProperty.DefaultValue = result.ToString();
  
          Properties.Settings.Default.Save();
      }
  }
  </code></pre>
  
  <p>It gets the new value from a mysql database.  If I add a MessageBox.Show to show the new value it seems to be working fine but it doesn't actually save it.  I assume this is because I am assigning the value to a variable...is there some way to do this?</p>
  
  <pre><code>Properties.Settings.Default.IndexOf(currentProperty.name).DefaultValue = result
  </code></pre>