HttpListenerPrefixCollection.CopyTo 方法     
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将 HttpListenerPrefixCollection 的内容复制到指定的数组。
重载
| CopyTo(Array, Int32) | 将 HttpListenerPrefixCollection 的内容复制到指定的数组。 | 
| CopyTo(String[], Int32) | 将 HttpListenerPrefixCollection 的内容复制到指定的字符串数组。 | 
注解
数组必须能够包含字符串,并且不能是多维的。
CopyTo(Array, Int32)
将 HttpListenerPrefixCollection 的内容复制到指定的数组。
public:
 void CopyTo(Array ^ array, int offset);public void CopyTo(Array array, int offset);member this.CopyTo : Array * int -> unitPublic Sub CopyTo (array As Array, offset As Integer)参数
- 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 的内容复制到指定的字符串数组。
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 -> unitPublic 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
注解
数组必须能够包含字符串,并且不能是多维的。