AppSettingsReader.GetValue : AppSettingsReader « System.Configuration « C# / C Sharp by API






AppSettingsReader.GetValue

 

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>
*/

   
  








Related examples in the same category