Redigera

Dela via


HttpListenerPrefixCollection.CopyTo Method

Definition

Copies the contents of an HttpListenerPrefixCollection to the specified array.

Overloads

CopyTo(Array, Int32)

Copies the contents of an HttpListenerPrefixCollection to the specified array.

CopyTo(String[], Int32)

Copies the contents of an HttpListenerPrefixCollection to the specified string array.

Remarks

The array must be able to contain strings and cannot be multidimensional.

CopyTo(Array, Int32)

Source:
HttpListenerPrefixCollection.cs
Source:
HttpListenerPrefixCollection.cs
Source:
HttpListenerPrefixCollection.cs

Copies the contents of an HttpListenerPrefixCollection to the specified array.

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)

Parameters

array
Array

The one dimensional Array that receives the Uniform Resource Identifier (URI) prefix strings in this collection.

offset
Int32

The zero-based index in array at which copying begins.

Exceptions

array has more than one dimension.

This collection contains more elements than can be stored in array starting at offset.

The HttpListener associated with this collection is closed.

array cannot store string values.

Examples

The following code example copies the prefixes in a 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

Remarks

The array must be able to contain strings and cannot be multidimensional.

See also

Applies to

CopyTo(String[], Int32)

Source:
HttpListenerPrefixCollection.cs
Source:
HttpListenerPrefixCollection.cs
Source:
HttpListenerPrefixCollection.cs

Copies the contents of an HttpListenerPrefixCollection to the specified string array.

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)

Parameters

array
String[]

The one dimensional string array that receives the Uniform Resource Identifier (URI) prefix strings in this collection.

offset
Int32

The zero-based index in array at which copying begins.

Implements

Exceptions

array has more than one dimension.

This collection contains more elements than can be stored in array starting at offset.

The HttpListener associated with this collection is closed.

Examples

The following code example copies the prefixes in a 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

Remarks

The array must be able to contain strings and cannot be multidimensional.

See also

Applies to