HttpListenerPrefixCollection.Contains(String) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Returns a Boolean value that indicates whether the specified prefix is contained in the 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
Parameters
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.
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
Remarks
The specified prefix must exactly match an existing value.
Applies to
See also
التعاون معنا على GitHub
يمكن العثور على مصدر هذا المحتوى على GitHub حيث يمكنك أيضاً إضافة مشاكل وطلبات سحب ومراجعتها. للحصول على معلومات إضافية، اطلع على دليل المساهم لدينا.