XmlSchemaObjectCollection.Add(XmlSchemaObject) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
在 XmlSchemaObjectXmlSchemaObjectCollection.
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加入收藏。
傳回
該項目被加入的索引。
例外狀況
XmlSchemaObject所指定的參數不屬於型別XmlSchemaExternal,也不是其導出型別XmlSchemaImport、 XmlSchemaInclude、 XmlSchemaRedefine。
備註
若 Count 已等於容量,則透過自動重新配置內部陣列並將現有元素複製至新陣列,將列表容量加倍,然後再加入新元素。
若 Count 小於容量,則此方法為 0(1) 運算。 若容量需增加以容納新元素,此方法將成為 0(n) 運算,其中 n 為 Count。
該 Add 方法僅 XmlSchemaExternal 期望 及其導出型別 (XmlSchemaImport, XmlSchemaInclude, 和 XmlSchemaRedefine) 作為參數。 以下範例說明將包含的結構加入 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);