var mySettings = (MySettingsSection) ConfigurationManager.GetSection("MySettings"); var mySetting = mySettings.MySetting;
var mySettings = new MySettingsSection(); mySettings.MySetting = "some value"; var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); config.Sections.Add("MySettings", mySettings); config.Save(ConfigurationSaveMode.Modified);This code creates a new instance of the MySettingsSection class, sets the value of its MySetting property, adds it to the app.config file as a new section, and saves the changes. Both examples use the System.Configuration namespace, which is included in the .NET Framework's System.Configuration package.