Export (0) Print
Expand All

ApplicationSettingsBase.Item Property

Gets or sets the value of the specified application settings property.

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

public override Object this[
	string propertyName
] { get; set; }

Parameters

propertyName
Type: System.String

A String containing the name of the property to access.

Property Value

Type: System.Object
If found, the value of the named settings property; otherwise, null.

ExceptionCondition
SettingsPropertyNotFoundException

There are no properties associated with the current wrapper or the specified property could not be found.

SettingsPropertyIsReadOnlyException

An attempt was made to set a read-only property.

SettingsPropertyWrongTypeException

The value supplied is of a type incompatible with the settings property, during a set operation.

ConfigurationErrorsException

The configuration file could not be parsed.

The Item property, also known as the indexer, is routinely used in the settings wrapper class derived from ApplicationSettingsBase. Item binds the public property of the wrapper class to the corresponding settings property.

Item raises several events depending on the operation being performed:

  • The first time a property is retrieved, the SettingsLoaded event is raised.

  • When a property is set, the OnSettingChanging event is raised. If the handler does not cancel the event, then the property value is set and the PropertyChanged event is raised.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft