Csharp/C Sharp by API/System.Configuration/AppSettingsReader
Версия от 15:31, 26 мая 2010; (обсуждение)
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>
*/