ConfigurationElement.Properties Property

Note: This property is new in the .NET Framework version 2.0.

Gets the collection of properties.

Namespace: System.Configuration
Assembly: System.Configuration (in system.configuration.dll)

protected internal virtual ConfigurationPropertyCollection Properties { get; 
/** @property */
protected ConfigurationPropertyCollection get_Properties ()

protected internal function get Properties () : ConfigurationPropertyCollection

Property Value

The ConfigurationPropertyCollection collection of properties for the element.

The Properties property, also called the property bag, contains all the properties (attributes) that apply to the element.

The following example shows how to use the Properties property.

// Show the use of Properties.
// It displays the ConfigurationElement 
// properties.
static void GetProperties()
{

    try
    {
        // Get the current configuration file.
        System.Configuration.Configuration config =
            ConfigurationManager.OpenExeConfiguration(
            ConfigurationUserLevel.None);

        // Get the configuration section MyUrls.
        UrlsSection myUrlsSection =
           config.Sections["MyUrls"] as UrlsSection;

        // Get the configuration element collection.
        UrlsCollection elements =
            myUrlsSection.Urls;

        IEnumerator elemEnum =
            elements.GetEnumerator();

        int i = 0;
        while (elemEnum.MoveNext())
        {
            // Get the current element configuration
            // property collection.
            PropertyInformationCollection properties =
                elements[i].ElementInformation.Properties;

            // Display the current configuration 
            // element properties.
            foreach (PropertyInformation property in properties)
            {
                Console.WriteLine("Name: {0\tDefault: {1\tRequired: {2",
                 property.Name, property.DefaultValue,
                 property.IsRequired.ToString());
            
        

    
    catch (ConfigurationErrorsException e)
    {
        Console.WriteLine("[GetProperties: {0]",
            e.ToString());
    



Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions

ADD
Show: