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.

C#
public void CopyTo(Array array, int offset);

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.

C#
public static string[] CopyPrefixes (HttpListener listener)
{
     HttpListenerPrefixCollection prefixes = listener.Prefixes;
     string[] prefixArray = new string[prefixes.Count];
     prefixes.CopyTo(prefixArray, 0);
     return prefixArray;
}

Remarks

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

See also

Applies to

.NET 10 och andra versioner
Produkt Versioner
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

CopyTo(String[], Int32)

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

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

C#
public void CopyTo(string[] array, int offset);

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.

C#
public static string[] CopyPrefixes (HttpListener listener)
{
     HttpListenerPrefixCollection prefixes = listener.Prefixes;
     string[] prefixArray = new string[prefixes.Count];
     prefixes.CopyTo(prefixArray, 0);
     return prefixArray;
}

Remarks

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

See also

Applies to

.NET 10 och andra versioner
Produkt Versioner
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1