Olvasás angol nyelven Szerkesztés

Megosztás a következőn keresztül:


HttpListenerPrefixCollection.Contains(String) Method

Definition

Returns a Boolean value that indicates whether the specified prefix is contained in the collection.

C#
public bool Contains(string uriPrefix);

Parameters

uriPrefix
String

A String that contains the Uniform Resource Identifier (URI) prefix to test.

Returns

true if this collection contains the prefix specified by uriPrefix; otherwise, false.

Implements

Exceptions

uriPrefix is null.

Examples

The following code example checks to see whether a user-specified prefix is contained in the prefix collection of an HttpListener.

C#
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);
}

Remarks

The specified prefix must exactly match an existing value.

Applies to

Termék Verziók
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

See also