How to read the app.config file in C#



I have been stuck on this for a while now. Basically I have an app.config file with multiple layers such as follows:



<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<configSections>
<section name ="Customer" type="ConfigTest.CustomerConfig"/>
</configSections>

<Customer>
<add key="ID" value="100"/>
<Addresses>
<Address>
<add key="Street" value ="12 Brit Street" />
<Otherinfo>
<Random>

<add key="Randoms" value="ignore this"/>

</Random>
</Otherinfo>

</Address>
</Addresses>
</Customer>
</configuration>


I am trying to extract this but I am having issues as the program only returns first layer. I am using this to access the first layer


Any help would be appreciated.


No comments:

Post a Comment