HttpListenerPrefixCollection.Contains(String) Método

Definición

Devuelve un valor Boolean que indica si la colección contiene el prefijo 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

String que contiene el prefijo URI (Identificador uniforme de recursos) que se va a comprobar.

Devoluciones

Es true si esta colección contiene el prefijo especificado por uriPrefix; en caso contrario, es false.

Implementaciones

Excepciones

uriPrefix es null.

Ejemplos

En el ejemplo de código siguiente se comprueba si un prefijo especificado por el usuario se encuentra en la colección de prefijos de .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

Comentarios

El prefijo especificado debe coincidir exactamente con un valor existente.

Se aplica a

Consulte también