PropertyDescriptorCollection.Count 属性

获取集合中属性说明符的数目。

**命名空间:**System.ComponentModel
**程序集:**System(在 system.dll 中)

语法

声明
Public ReadOnly Property Count As Integer
用法
Dim instance As PropertyDescriptorCollection
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 属性设置循环访问对象集合的循环的界限。因为集合是从零开始的,所以务必使用 Count - 1 作为循环的上限。

示例

下面的代码示例使用 Count 属性来输出 button1 上属性的数目。它要求已在窗体上实例化 button1textBox1

Private Sub GetCount()
    ' Creates a new collection and assign it the properties for button1.
    Dim properties As PropertyDescriptorCollection = TypeDescriptor.GetProperties(button1)
       
    ' Prints the number of properties on button1 in a textbox.
    textBox1.Text = properties.Count.ToString()
End Sub
private void GetCount() {
    // Creates a new collection and assign it the properties for button1.
    PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(button1);
 
    // Prints the number of properties on button1 in a textbox.
    textBox1.Text = properties.Count.ToString();
 }
private:
   void GetCount()
   {
      // Creates a new collection and assign it the properties for button1.
      PropertyDescriptorCollection^ properties = TypeDescriptor::GetProperties( button1 );
      
      // Prints the number of properties on button1 in a textbox.
      textBox1->Text = properties->Count.ToString();
   }
private void GetCount()
{
    // Creates a new collection and assign it the properties for button1.
    PropertyDescriptorCollection properties =
        TypeDescriptor.GetProperties(button1);

    // Prints the number of properties on button1 in a textbox.
    textBox1.set_Text(System.Convert.ToString(properties.get_Count()));
} //GetCount

平台

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

请参见

参考

PropertyDescriptorCollection 类
PropertyDescriptorCollection 成员
System.ComponentModel 命名空间
PropertyDescriptor 类
TypeDescriptor