AttributeCollection.Count 属性

获取属性 (Attribute) 的数目。

**命名空间:**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

属性值

属性 (Attribute) 的数目。

备注

可以使用 Count 属性 (Property) 设置循环访问对象集合的循环的界限。如果集合是从零开始的,务必使用 Count - 1 作为循环的上限。

示例

下面的代码示例使用 Count 属性 (Property) 在文本框中输出 button1 上属性 (Property) 的数目。它假定已经在窗体上创建了 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