다음을 통해 공유


AttributeCollection.Count 속성

특성의 개수를 가져옵니다.

네임스페이스: System.ComponentModel
어셈블리: System(system.dll)

구문

‘선언
Public ReadOnly Property Count As Integer
‘사용 방법
Dim instance As AttributeCollection
Dim value As Integer

value = instance.Count
public int Count { get; }
public:
property int Count {
    int get ();
}
/** @property */
public int get_Count ()
public function get Count () : int

속성 값

특성의 개수입니다.

설명

Count 속성을 사용하여 개체 컬렉션을 반복하는 루프의 한계를 설정할 수 있습니다. 컬렉션이 0에서 시작하면 루프의 상한값으로 Count - 1을 사용해야 합니다.

예제

다음 코드 예제에서는 Count 속성을 사용하여 텍스트 상자에 button1의 속성 수를 출력합니다. 여기에서는 폼에 button1textBox1이 만들어져 있는 것으로 가정합니다.

Private Sub GetCount
    ' Creates a new collection and assigns it the attributes for button 1.
    Dim attributes As AttributeCollection
    attributes = TypeDescriptor.GetAttributes(button1)
    ' Prints the number of items in the collection.
    textBox1.Text = attributes.Count.ToString
End Sub
private void GetCount() {
    // Creates a new collection and assigns it the attributes for button1.
    AttributeCollection attributes;
    attributes = TypeDescriptor.GetAttributes(button1);
 
    // Prints the number of items in the collection.
    textBox1.Text = attributes.Count.ToString();
 }
private:
   void GetCount()
   {
      // Creates a new collection and assigns it the attributes for button1.
      AttributeCollection^ attributes;
      attributes = TypeDescriptor::GetAttributes( button1 );
      
      // Prints the number of items in the collection.
      textBox1->Text = attributes->Count.ToString();
   }
private void GetCount()
{
    // Creates a new collection and assigns it the attributes for button1.
    AttributeCollection attributes;
    attributes = TypeDescriptor.GetAttributes(button1);
    // Prints the number of items in the collection.
    textBox1.set_Text(((Int32)attributes.get_Count()).ToString());
} //GetCount
private function GetCount() {
    // Create a new collection and assign it the attributes for button1.
    var attributes : AttributeCollection;
    attributes = TypeDescriptor.GetAttributes(button1);
 
    // Print the number of items in the collection.
    textBox1.Text = attributes.Count.ToString();
 }

플랫폼

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

.NET Compact Framework

2.0, 1.0에서 지원

참고 항목

참조

AttributeCollection 클래스
AttributeCollection 멤버
System.ComponentModel 네임스페이스
Attribute