NameValueConfigurationCollection.Add(NameValueConfigurationElement) Methode
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Hiermee voegt u een NameValueConfigurationElement object toe aan de verzameling.
public:
void Add(System::Configuration::NameValueConfigurationElement ^ nameValue);
public void Add(System.Configuration.NameValueConfigurationElement nameValue);
member this.Add : System.Configuration.NameValueConfigurationElement -> unit
Public Sub Add (nameValue As NameValueConfigurationElement)
Parameters
- nameValue
- NameValueConfigurationElement
Een NameValueConfigurationElement-object.
Voorbeelden
In het volgende codevoorbeeld ziet u hoe u de Add methode gebruikt. Dit codevoorbeeld maakt deel uit van een groter voorbeeld voor de NameValueConfigurationCollection klasse.
foreach (PropertyInformation propertyItem in
configSection.ElementInformation.Properties)
{
// Assign domain name.
if (propertyItem.Name == "domain")
propertyItem.Value = "MyDomain";
if (propertyItem.Value != null)
{
// Enable SSL for cookie exchange.
if (propertyItem.Name == "cookieRequireSSL")
propertyItem.Value = true;
NameValueConfigurationElement nameValConfigElement =
new NameValueConfigurationElement
(propertyItem.Name.ToString(), propertyItem.Value.ToString());
// Add a NameValueConfigurationElement
// to the collection.
myNameValConfigCollection.Add(nameValConfigElement);
}
}
For Each propertyItem As PropertyInformation In configSection.ElementInformation.Properties
' Assign domain name.
If propertyItem.Name = "domain" Then
propertyItem.Value = "MyDomain"
End If
If propertyItem.Value <> Nothing Then
' Enable SSL for cookie exchange.
If propertyItem.Name = "cookieRequireSSL" Then
propertyItem.Value = True
End If
Dim nameValConfigElement As New NameValueConfigurationElement(propertyItem.Name.ToString(), propertyItem.Value.ToString())
' Add a NameValueConfigurationElement
' to the collection.
myNameValConfigCollection.Add(nameValConfigElement)
End If
Next
Opmerkingen
Gebruik de Add methode om een nieuw NameValueConfigurationElement object toe te voegen aan de verzameling.