Skip to content

Instantly share code, notes, and snippets.

@caglartoklu
Last active December 13, 2015 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caglartoklu/4954533 to your computer and use it in GitHub Desktop.
Save caglartoklu/4954533 to your computer and use it in GitHub Desktop.
Simple app.config usage in C#. #cs #config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<appSettings>
<add key="one" value="1"/>
<add key="two" value="2"/>
<add key="three" value="3"/>
<add key="four" value="4"/>
</appSettings>
</configuration>
namespace myapp
{
// Make sure you add a reference to System.Configuration.dll.
// http://msdn.microsoft.com/en-us/library/system.configuration.appsettingsreader.aspx
using System;
using System.Collections.Specialized;
using System.Configuration;
class Program
{
static void Main(string[] args)
{
AppSettingsReader reader = new AppSettingsReader();
NameValueCollection appSettings = ConfigurationManager.AppSettings;
Console.WriteLine(appSettings["two"]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment