ConfigurationElementCollection.CreateNewElement 方法
本文内容
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
在派生的类中重写时,创建一个新的 ConfigurationElement。
CreateNewElement(String) |
在派生的类中重写时,创建新的 ConfigurationElement。 |
CreateNewElement() |
在派生的类中重写时,创建一个新的 ConfigurationElement。 |
CreateNewElement重写 方法以创建特定类型的自定义ConfigurationElement对象。 从配置文件加载集合时, CreateNewElement 调用 以创建单个元素。 CreateNewElement 必须在派生自 ConfigurationElementCollection 类的类中重写。
在派生的类中重写时,创建新的 ConfigurationElement。
protected:
virtual System::Configuration::ConfigurationElement ^ CreateNewElement(System::String ^ elementName);
protected virtual System.Configuration.ConfigurationElement CreateNewElement (string elementName);
abstract member CreateNewElement : string -> System.Configuration.ConfigurationElement
override this.CreateNewElement : string -> System.Configuration.ConfigurationElement
Protected Overridable Function CreateNewElement (elementName As String) As ConfigurationElement
参数
- elementName
- String
要创建的 ConfigurationElement 的名称。
返回
一个新的具有指定名称的 ConfigurationElement。
注解
CreateNewElement重写 方法以创建特定类型的自定义ConfigurationElement对象。 从配置文件加载集合时, CreateNewElement 调用 以创建单个元素。 CreateNewElement 必须在派生自 ConfigurationElementCollection 类的类中重写。
继承者说明
如果创建包含异类ConfigurationElement类型的自定义ConfigurationElementCollection集合,则必须执行以下步骤:
确保 GetElementKey(ConfigurationElement) 方法返回一个字符串,用于标识通过调用 CreateNewElement(String) 方法创建的元素的类型。
适用于
.NET Framework 4.8.1 和其他版本
产品 | 版本 |
---|---|
.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 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9 |
在派生的类中重写时,创建一个新的 ConfigurationElement。
protected:
abstract System::Configuration::ConfigurationElement ^ CreateNewElement();
protected abstract System.Configuration.ConfigurationElement CreateNewElement ();
abstract member CreateNewElement : unit -> System.Configuration.ConfigurationElement
Protected MustOverride Function CreateNewElement () As ConfigurationElement
返回
一个新创建的 ConfigurationElement。
示例
下面的代码示例演示如何重写 CreateNewElement 方法。
protected override ConfigurationElement CreateNewElement()
{
return new UrlConfigElement();
}
Protected Overloads Overrides Function CreateNewElement() As ConfigurationElement
Return New UrlConfigElement()
End Function
注解
CreateNewElement重写 方法以创建特定类型的自定义ConfigurationElement对象。 从配置文件加载集合时, CreateNewElement 调用 以创建单个元素。 CreateNewElement 必须在派生自 ConfigurationElementCollection 类的类中重写。
适用于
.NET Framework 4.8.1 和其他版本
产品 | 版本 |
---|---|
.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 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9 |