This documentation is archived and is not being maintained.

HttpListenerPrefixCollection.Contains Method

Note: This method is new in the .NET Framework version 2.0.

Returns a Boolean value that indicates whether the specified prefix is contained in the collection.

Namespace: System.Net
Assembly: System (in system.dll)

virtual bool Contains (
	String^ uriPrefix
) sealed
public final boolean Contains (
	String uriPrefix
public final function Contains (
	uriPrefix : String
) : boolean



A String that contains the Uniform Resource Identifier (URI) prefix to test.

Return Value

true if this collection contains the prefix specified by uriPrefix; otherwise, false.

Exception typeCondition


uriPrefix is a null reference (Nothing in Visual Basic).

The specified prefix must exactly match an existing value.

The following code example checks to see whether a user-specified prefix is contained in the prefix collection of an HttpListener.

public static bool CheckForPrefix(HttpListener listener, string prefix)
    // Get the prefixes that the Web server is listening to.
    HttpListenerPrefixCollection prefixes = listener.Prefixes;
    if (prefixes.Count == 0 || prefix == null)
        return false;
    return prefixes.Contains(prefix);

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0