views:

357

answers:

1

How do I create a custom app.config section that is just a simple list of add elements?

I have found a few examples (e.g. http://stackoverflow.com/questions/1316058) for custom sections that look like this:

<RegisterCompanies>
  <Companies>
    <Company name="Tata Motors" code="Tata"/>
    <Company name="Honda Motors" code="Honda"/>
  </Companies>
</RegisterCompanies>

But how do I avoid the extra collection element ("Companies") so that it looks the same as the appSettings and connectionStrings sections? In other words, I'd like:

<registerCompanies>
  <add name="Tata Motors" code="Tata"/>
  <add name="Honda Motors" code="Honda"/>
</registerCompanies>
A: 

Check out http://jopinblog.wordpress.com/2007/04/20/custom-configurationsections-in-net-20-config-files/

kervin
Perfect, thanks.
Joe Daley
You're welcome!
kervin