// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Configuration; namespace E { public class MyConfig : ConfigurationSection { [ConfigurationProperty("foo")] public int Foo { get { return (int)this["foo"]; } } [ConfigurationProperty("bar")] public string Bar { get { return (string)this["bar"]; } } } public class Program { public static void Main(string[] args) { MyConfig cfg = (MyConfig)ConfigurationManager.GetSection("myconfig"); Console.WriteLine(cfg.Foo + " " + cfg.Bar); } } }