XmlSchemaObjectCollection.Add(XmlSchemaObject) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
向 . XmlSchemaObjectCollection添加一个 XmlSchemaObject 。
public:
int Add(System::Xml::Schema::XmlSchemaObject ^ item);
public int Add(System.Xml.Schema.XmlSchemaObject item);
member this.Add : System.Xml.Schema.XmlSchemaObject -> int
Public Function Add (item As XmlSchemaObject) As Integer
参数
- item
- XmlSchemaObject
XmlSchemaObject要添加到集合中。
返回
在其中添加项的索引。
例外
注解
如果 Count 已等于容量,则通过自动重新分配内部数组并将现有元素复制到新数组,在添加新元素之前,列表的容量会翻倍。
如果 Count 容量小于容量,则此方法为 0(1) 操作。 如果需要增加容量以适应新元素,此方法将变为 0(n) 运算,其中 n。Count
该方法Add仅XmlSchemaExternal需要其派生类型(XmlSchemaRedefineXmlSchemaImportXmlSchemaInclude和)作为参数。 下面的示例演示如何将包含的架构添加到 Includes 现有 XmlSchema 对象的集合。
Dim schema As XmlSchema = New XmlSchema()
Dim textReader As XmlTextReader = New XmlTextReader("include.xsd")
Dim includeSchema As XmlSchema = XmlSchema.Read(textReader, null)
Dim include As XmlSchemaInclude = New XmlSchemaInclude()
include.Schema = includeSchema;
schema.Includes.Add(include);
XmlSchema schema = new XmlSchema();
XmlTextReader textReader = new XmlTextReader("include.xsd");
XmlSchema includeSchema = XmlSchema.Read(textReader, null);
XmlSchemaInclude include = new XmlSchemaInclude();
include.Schema = includeSchema;
schema.Includes.Add(include);