HttpListenerPrefixCollection.Contains(String) Metoda

Definice

Boolean Vrátí hodnotu, která určuje, jestli je zadaná předpona obsažena v kolekci.

public:
 virtual bool Contains(System::String ^ uriPrefix);
public bool Contains (string uriPrefix);
abstract member Contains : string -> bool
override this.Contains : string -> bool
Public Function Contains (uriPrefix As String) As Boolean

Parametry

uriPrefix
String

A String , který obsahuje předponu identifikátoru URI (Uniform Resource Identifier), která se má testovat.

Návraty

Boolean

true pokud tato kolekce obsahuje předponu určenou uriPrefix; v opačném případě false.

Implementuje

Výjimky

uriPrefix je null.

Příklady

Následující příklad kódu zkontroluje, zda je předpona zadaná uživatelem obsažena v kolekci předpony 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 Shared Function CheckForPrefix(ByVal listener As HttpListener, ByVal prefix As String) As Boolean
    Dim prefixes As HttpListenerPrefixCollection = listener.Prefixes

    ' Get the prefixes that the Web server is listening to.
    If prefixes.Count = 0 OrElse prefix Is Nothing Then
        Return False
    End If

    Return prefixes.Contains(prefix)
End Function

Poznámky

Zadaná předpona musí přesně odpovídat existující hodnotě.

Platí pro

Viz také