HttpListenerPrefixCollection.Contains(String) メソッド

定義

指定したプレフィックスがコレクションに含まれているかどうかを示す Boolean 値を返します。

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

パラメーター

uriPrefix
String

テストする Uniform Resource Identifier (URI) プレフィックスを格納している String

戻り値

Boolean

このコレクションに uriPrefix で指定したプレフィックスが存在する場合は true、それ以外の場合は false

実装

例外

uriPrefixnullです。

次のコード例では、ユーザー指定のプレフィックスがプレフィックス コレクション 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

注釈

指定したプレフィックスは、既存の値と完全に一致している必要があります。

適用対象

こちらもご覧ください