PropertyDescriptorCollection.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 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();
}
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 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
注解
可以使用该 Count 属性设置循环访问对象集合的限制。 由于集合是从零开始的,因此请确保用作 Count - 1 循环的上限。