อ่านในภาษาอังกฤษ แก้ไข

แชร์ผ่าน


ConfigurationElementCollection.CreateNewElement Method

Definition

When overridden in a derived class, creates a new ConfigurationElement.

Overloads

CreateNewElement(String)

Creates a new ConfigurationElement when overridden in a derived class.

CreateNewElement()

When overridden in a derived class, creates a new ConfigurationElement.

Remarks

Override the CreateNewElement method to create custom ConfigurationElement objects of a specific type. When a collection is loaded from the configuration file, CreateNewElement is called to create individual elements. CreateNewElement must be overridden in classes that derive from the ConfigurationElementCollection class.

CreateNewElement(String)

Source:
ConfigurationElementCollection.cs
Source:
ConfigurationElementCollection.cs
Source:
ConfigurationElementCollection.cs
Source:
ConfigurationElementCollection.cs
Source:
ConfigurationElementCollection.cs
Source:
ConfigurationElementCollection.cs

Creates a new ConfigurationElement when overridden in a derived class.

C#
protected virtual System.Configuration.ConfigurationElement CreateNewElement(string elementName);

Parameters

elementName
String

The name of the ConfigurationElement to create.

Returns

A new ConfigurationElement with a specified name.

Remarks

Override the CreateNewElement method to create custom ConfigurationElement objects of a specific type. When a collection is loaded from the configuration file, CreateNewElement is called to create individual elements. CreateNewElement must be overridden in classes that derive from the ConfigurationElementCollection class.

Notes to Inheritors

If you create a custom ConfigurationElementCollection collection that contains heterogeneous ConfigurationElement types, you must perform these steps:

Applies to

.NET 10 (package-provided) และรุ่นอื่นๆ
ผลิตภัณฑ์ เวอร์ชัน
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

CreateNewElement()

Source:
ConfigurationElementCollection.cs
Source:
ConfigurationElementCollection.cs
Source:
ConfigurationElementCollection.cs
Source:
ConfigurationElementCollection.cs
Source:
ConfigurationElementCollection.cs
Source:
ConfigurationElementCollection.cs

When overridden in a derived class, creates a new ConfigurationElement.

C#
protected abstract System.Configuration.ConfigurationElement CreateNewElement();

Returns

A newly created ConfigurationElement.

Examples

The following code example shows how to override the CreateNewElement method.

C#
protected override ConfigurationElement CreateNewElement()
{
    return new UrlConfigElement();
}

Remarks

Override the CreateNewElement method to create custom ConfigurationElement objects of a specific type. When a collection is loaded from the configuration file, CreateNewElement is called to create individual elements. CreateNewElement must be overridden in classes that derive from the ConfigurationElementCollection class.

Applies to

.NET 10 (package-provided) และรุ่นอื่นๆ
ผลิตภัณฑ์ เวอร์ชัน
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10