Use AppSettingsReader to load settings from app.config : AppSettingsReader « Development « C# / CSharp Tutorial






using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

public class MainClass {

  [STAThread]
  static void Main() 
  {
    System.Configuration.AppSettingsReader configurationAppSettings = new System.Configuration.AppSettingsReader();
    Console.WriteLine((string)(configurationAppSettings.GetValue("label1.Text", typeof(string))));

  }

}
/* app.config
<?xml version="1.0" encoding="Windows-1252"?>
<configuration>
  <appSettings>
    <!--   User application and configured property settings go here.-->
    <!--   Example: <add key="settingName" value="settingValue"/> -->
    <add key="label1.Text" value="label1" />
  </appSettings>
</configuration>

*/








14.12.AppSettingsReader
14.12.1.Use AppSettingsReader to load settings from app.config
14.12.2.For programmatic access to .NET *.config files
14.12.3.Store ConnectionStringConfig solution