Can someone explain, in plain English, the difference between ConfigurationSection and ConfigurationElement?
I'm reading through a fantastic article on the .NET Configuration namespace (found here) which talks about creating custom sections, elements, collections, widgets, 开发者_JAVA技巧and flying toasters. The only complaint I have is that the article is only technical and doesn't provide any conceptual context. MSDN doesn't appear to have much conceptual information, either.
So can someone explain, please, what a "section" is, what an "element" is, and when it would be appropriate to use each?
I think a better read for you will be this series of articles, which brilliantly tells you about all the details of configurations in C#:
Unraveling the Mysteries of .NET 2.0 Configuration
Decoding the Mysteries of .NET 2.0 Configuration
Cracking the Mysteries of .NET 2.0 Configuration
And to answer your question in simple words, ConfigurationSection
is a container which contains multiple ConfigurationElement
and/or ConfigurationElementCollection
. The parent of ConfigurationSection
will always be <configuration>
which is the root element in configuration files.
ConfigurationElement
is a container and/or single element and is always part of a ConfigurationSection
.
精彩评论