共用方式為


XmlSerializerNamespaces.ToArray 方法

定義

取得 XmlSerializerNamespaces 物件中前置詞和命名空間配對的陣列。

public:
 cli::array <System::Xml::XmlQualifiedName ^> ^ ToArray();
public System.Xml.XmlQualifiedName[] ToArray ();
member this.ToArray : unit -> System.Xml.XmlQualifiedName[]
Public Function ToArray () As XmlQualifiedName()

傳回

XmlQualifiedName 物件的陣列,在 XML 文件中用作限定名稱。

範例

下列範例會在 物件中 XmlSerializerNamespaces 列印每個 NameNamespace

private:
   void PrintNamespacePairs( XmlSerializerNamespaces^ namespaces )
   {
      array<XmlQualifiedName^>^ qualifiedNames = namespaces->ToArray();
      for ( int i = 0; i < qualifiedNames->Length; i++ )
      {
         Console::WriteLine( "{0}\t{1}",
            qualifiedNames[ i ]->Name, qualifiedNames[ i ]->Namespace );
      }
   }
private void PrintNamespacePairs(XmlSerializerNamespaces namespaces)
{
   XmlQualifiedName[] qualifiedNames = namespaces.ToArray();
   for(int i = 0; i < qualifiedNames.Length; i++)
   {
      Console.WriteLine
      (
      qualifiedNames[i].Name + "\t" +
      qualifiedNames[i].Namespace
      );
   }
}
Private Sub PrintNamespacePairs(ByVal namespaces As XmlSerializerNamespaces)
    Dim qualifiedNames() As XmlQualifiedName = namespaces.ToArray()
    Dim i As Integer
    For i = 0 To qualifiedNames.Length - 1
        Console.WriteLine(qualifiedNames(i).Name & ControlChars.Tab & _
                          qualifiedNames(i).Namespace)
    Next i
End Sub

適用於