HttpListenerPrefixCollection.Contains(String) Método

Definição

Retorna um valor de Boolean que indica se a coleção contém ou não o prefixo especificado.

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

Parâmetros

uriPrefix
String

Um String que contém o prefixo de URI (Uniform Resource Identifier) a testar.

Retornos

true se esta coleção contém o prefixo especificado por uriPrefix; caso contrário, false.

Implementações

Exceções

uriPrefix é null.

Exemplos

O exemplo de código a seguir verifica se um prefixo especificado pelo usuário está contido na coleção de prefixos de um 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

Comentários

O prefixo especificado deve corresponder exatamente a um valor existente.

Aplica-se a

Confira também