Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linq to XML - Multiple Elements into Single Class

Tags:

c#

linq-to-xml

I have the following XML:

<appSettings>
   <add key="Prop1" value="1" />
   <add key="Prop2" value="2" />
</appSettings>

Is there a LINQ to XML query to load this section to a single instance of a ConfigProp class?

public class ConfigProp
{
   public string Prop1 {get; set;}
   public string Prop2 {get; set;}
}
like image 817
Bill Avatar asked Aug 29 '26 07:08

Bill


1 Answers

Why you dont't use this?

System.Configuration.ConfigurationManager.AppSettings["Prop1"];
like image 71
Vadim Sentiaev Avatar answered Aug 30 '26 19:08

Vadim Sentiaev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!