HttpListenerPrefixCollection.Contains(String) Méthode

Définition

Retourne une valeur Boolean qui indique si le préfixe spécifié est contenu dans la collection.

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

Paramètres

uriPrefix
String

String qui contient le préfixe URI (Uniform Resource Identifier) à tester.

Retours

Boolean

true si la collection contient le préfixe spécifié par uriPrefix ; sinon, false.

Implémente

Exceptions

uriPrefix a la valeur null.

Exemples

L’exemple de code suivant vérifie si un préfixe spécifié par l’utilisateur est contenu dans la collection de préfixes d’un 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

Remarques

Le préfixe spécifié doit correspondre exactement à une valeur existante.

S’applique à

Voir aussi