HttpListenerPrefixCollection.Count 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取集合中包含的前缀数。
public:
property int Count { int get(); };
public int Count { get; }
member this.Count : int
Public ReadOnly Property Count As Integer
属性值
一个 Int32,包含此集合中的前缀的数目。
实现
示例
下面的代码示例显示集合中的前缀。
public static void DisplayPrefixesAndState(HttpListener listener)
{
// List the prefixes to which the server listens.
HttpListenerPrefixCollection prefixes = listener.Prefixes;
if (prefixes.Count == 0)
{
Console.WriteLine("There are no prefixes.");
}
foreach(string prefix in prefixes)
{
Console.WriteLine(prefix);
}
// Show the listening state.
if (listener.IsListening)
{
Console.WriteLine("The server is listening.");
}
}
Public Shared Sub DisplayPrefixesAndState(ByVal listener As HttpListener)
' List the prefixes to which the server listens.
Dim prefixes As HttpListenerPrefixCollection = listener.Prefixes
If prefixes.Count = 0 Then
Console.WriteLine("There are no prefixes.")
End If
For Each prefix As String In prefixes
Console.WriteLine(prefix)
Next
' Show the listening state.
If listener.IsListening Then
Console.WriteLine("The server is listening.")
End If
End Sub