다음을 통해 공유


EventDescriptorCollection.Count 속성

정의

컬렉션의 이벤트 설명자 수를 가져옵니다.

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 속성을 사용하여 개체 컬렉션을 반복하는 루프의 제한을 설정할 수 있습니다. 컬렉션이 0부터 시작하는 경우 루프의 상한으로 사용해야 Count - 1 합니다.

메모

이 클래스에 적용된 특성에는 HostProtectionAttribute 다음과 같은 Resources 속성 값 Synchronization이 있습니다. 데스크톱 애플리케이션에는 HostProtectionAttribute 영향을 주지 않습니다(일반적으로 아이콘을 두 번 클릭하거나 명령을 입력하거나 브라우저에서 URL을 입력하여 시작됨). 자세한 내용은 클래스 또는 SQL Server 프로그래밍 및 호스트 보호 특성을 참조 HostProtectionAttribute 하세요.

적용 대상

추가 정보