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