Using app.config file in C# Visual Studio

If  would like to read some value from app.config file follow these steps.

1,Add System Configuration namespace to reference

Otherwise you will get 'ConfigurationManager' does not exist error

2,Import name space

using System.Configuration

3,Read String from config file


4,Sample App.config file

<?xml version="1.0" encoding="utf-8" ?>

    <add name="SqlConnectionString" 
connectionString="Data Source=localhost\SQLEXPRESS;Initial 
Catalog=library;Integrated Security=True;" />


No comments:

^ Top