HttpListenerPrefixCollection.CopyTo 方法

定義

HttpListenerPrefixCollection 的內容複製至指定的陣列。

多載

CopyTo(Array, Int32)

HttpListenerPrefixCollection 的內容複製至指定的陣列。

CopyTo(String[], Int32)

HttpListenerPrefixCollection 的內容複製至指定的字串陣列。

備註

陣列必須能夠包含字串,而且不能是多維度。

CopyTo(Array, Int32)

來源:
HttpListenerPrefixCollection.cs
來源:
HttpListenerPrefixCollection.cs
來源:
HttpListenerPrefixCollection.cs

HttpListenerPrefixCollection 的內容複製至指定的陣列。

public:
 void CopyTo(Array ^ array, int offset);
public void CopyTo (Array array, int offset);
member this.CopyTo : Array * int -> unit
Public Sub CopyTo (array As Array, offset As Integer)

參數

array
Array

一維 Array,接收這個集合中的統一資源識別元 (URI) 前置詞字串。

offset
Int32

array 中以零起始的索引,即開始複製的位置。

例外狀況

array 具有多個維度。

這個集合所包含的項目數目大於可以儲存在 array (從 offset 開始) 中的項目數目。

與此集合相關聯的 HttpListener 已關閉。

array 無法儲存字串值。

範例

下列程式碼範例會複製 中的 HttpListenerPrefixCollection 前置詞。

public static string[] CopyPrefixes (HttpListener listener)
{
     HttpListenerPrefixCollection prefixes = listener.Prefixes;
     string[] prefixArray = new string[prefixes.Count];
     prefixes.CopyTo(prefixArray, 0);
     return prefixArray;
}
Public Shared Function CopyPrefixes(ByVal listener As HttpListener) As String()
    Dim prefixes As HttpListenerPrefixCollection = listener.Prefixes
    Dim prefixArray As String() = New String(prefixes.Count - 1) {}
    prefixes.CopyTo(prefixArray, 0)
    Return prefixArray
End Function

備註

陣列必須能夠包含字串,而且不能是多維度。

另請參閱

適用於

CopyTo(String[], Int32)

來源:
HttpListenerPrefixCollection.cs
來源:
HttpListenerPrefixCollection.cs
來源:
HttpListenerPrefixCollection.cs

HttpListenerPrefixCollection 的內容複製至指定的字串陣列。

public:
 virtual void CopyTo(cli::array <System::String ^> ^ array, int offset);
public void CopyTo (string[] array, int offset);
abstract member CopyTo : string[] * int -> unit
override this.CopyTo : string[] * int -> unit
Public Sub CopyTo (array As String(), offset As Integer)

參數

array
String[]

一維字串陣列,接收這個集合中的統一資源識別元 (URI) 前置詞字串。

offset
Int32

array 中以零起始的索引,即開始複製的位置。

實作

例外狀況

array 具有多個維度。

這個集合所包含的項目數目大於可以儲存在 array (從 offset 開始) 中的項目數目。

與此集合相關聯的 HttpListener 已關閉。

範例

下列程式碼範例會複製 中的 HttpListenerPrefixCollection 前置詞。

public static string[] CopyPrefixes (HttpListener listener)
{
     HttpListenerPrefixCollection prefixes = listener.Prefixes;
     string[] prefixArray = new string[prefixes.Count];
     prefixes.CopyTo(prefixArray, 0);
     return prefixArray;
}
Public Shared Function CopyPrefixes(ByVal listener As HttpListener) As String()
    Dim prefixes As HttpListenerPrefixCollection = listener.Prefixes
    Dim prefixArray As String() = New String(prefixes.Count - 1) {}
    prefixes.CopyTo(prefixArray, 0)
    Return prefixArray
End Function

備註

陣列必須能夠包含字串,而且不能是多維度。

另請參閱

適用於