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 文档中用作限定名的 XmlQualifiedName 对象的数组。

示例

以下示例打印每个 Name 对象和 Namespace 对象 XmlSerializerNamespaces 中。

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

适用于