EventDescriptorCollection.Count 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得集合中事件描述符的數量。
public:
property int Count { int get(); };
public int Count { get; }
member this.Count : int
Public ReadOnly Property Count As Integer
屬性值
集合中事件描述符的數量。
實作
範例
以下程式碼範例使用屬性 Count 來列印與 button1相連的事件數量。 它需要這個, button1 並且 textBox1 已經在表單上實例化。
private:
void GetCount()
{
// Creates a new collection and assigns it the events for button1.
EventDescriptorCollection^ events = TypeDescriptor::GetEvents( button1 );
// Prints the number of events on button1 in a text box.
textBox1->Text = events->Count.ToString();
}
void GetCount()
{
// Creates a new collection and assigns it the events for button1.
EventDescriptorCollection events = TypeDescriptor.GetEvents(button1);
// Prints the number of events on button1 in a text box.
textBox1.Text = events.Count.ToString();
}
Private Sub GetCount()
' Creates a new collection and assigns it the events for button1.
Dim events As EventDescriptorCollection = TypeDescriptor.GetEvents(button1)
' Prints the number of events on button1 in a text box.
textBox1.Text = events.Count.ToString()
End Sub
備註
此 Count 特性可用來設定迴圈的極限,迴圈會遍歷一組物件。 若集合為零基,務必將 作為 Count - 1 迴圈的上界。
備註
HostProtectionAttribute套用於此類別的屬性具有以下Resources屬性值: Synchronization。 這 HostProtectionAttribute 不會影響桌面應用程式(通常透過雙擊圖示、輸入指令或在瀏覽器輸入網址來啟動)。 欲了解更多資訊,請參閱 HostProtectionAttribute 類別或 SQL Server 程式設計與主機保護屬性。