XDocument to read value from AppSettings section in C#

Rajnilari2015
Posted by Rajnilari2015 under C# category on | Points: 40 | Views : 2287
The below program will do the work

using System;
using System.Xml.Linq;

namespace Test
{
class Program
{
static void Main(string[] args)
{
XDocument
.Load(@".\Web.config")
.Descendants("appSettings")
.Descendants("add")
.ToList()
.Foreach(element=>Console.WriteLine($"SET {element.FirstAttribute.Value}=\"{element.LastAttribute.Value}\""));

Console.ReadKey();
}
}
}

Comments or Responses

Login to post response