For programmatic access to .NET *.config files : AppSettingsReader : Development C# Examples


C# Examples » Development » AppSettingsReader »

 

For programmatic access to .NET *.config files









    
using  System;
using  System.Configuration;

class  MainClass
{
    static  void  Main(string[]  args)
    {
        AppSettingsReader  ar  =  new  AppSettingsReader();
        Console.WriteLine("Here  is  your  conn  string");
        Console.WriteLine(ar.GetValue("appConStr",  typeof(string)));
        Console.WriteLine();
        int  numbOfTimes  =  (int)ar.GetValue("intValue",  typeof(int));
        for(int  i  =  0;  i  <  numbOfTimes;  i++)
            Console.WriteLine("Yo!");
    }
}
/*
<?xml  version="1.0"  encoding="utf-8"  ?>
<configuration>
    <appSettings>
        <add  key="appConStr"  value="server=localhost;uid=sa;pwd=;database=Cars"  />
        <add  key="intValue"  value="4"  />
    </appSettings>
</configuration>
*/
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Development
» AppSettingsReader