Export (0) Print
Expand All

HttpListenerPrefixCollection.Contains Method

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

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

'Declaration
Public Function Contains ( _
	uriPrefix As String _
) As Boolean
'Usage
Dim instance As HttpListenerPrefixCollection
Dim uriPrefix As String
Dim returnValue As Boolean

returnValue = instance.Contains(uriPrefix)
public final boolean Contains (
	String uriPrefix
)
public final function Contains (
	uriPrefix : String
) : boolean
Not applicable.

Parameters

uriPrefix

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

ArgumentNullException

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);
}

public static boolean CheckForPrefix(HttpListener listener, String prefix)
{
    // Get the prefixes that the Web server is listening to.
    HttpListenerPrefixCollection prefixes = listener.get_Prefixes();
    if (prefixes.get_Count() == 0 || prefix == null) {
        return false;
    }
    return prefixes.Contains(prefix);
} //CheckForPrefix

Windows 98, Windows Server 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 Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft