IList.Item 属性

.NET Framework 类库  

IList.Item 属性

通过类实现时,获取或设置在指定的索引处的元素。

[C#] 在 C# 中,该属性为 IList 类的索引器。

[Visual Basic]
Default Property Item( _
ByVal index As Integer _
) As Object
[C#]
object this[
int index
] {get; set;}
[C++]
__property Object* get_Item(
   int index
);
__property void set_Item(
   int index,
   Object*
);
[JScript]
returnValue = IListObject.Item(index);
IListObject.Item(index) = returnValue;
- 或 -
returnValue = IListObject(index);
IListObject(index) = returnValue;

[JScript] 在 JScript 中,可以使用由某个类型定义的默认索引属性,但不能显式定义自己的索引属性。但是,在某个类上指定 expando 特性将自动提供一个类型为 Object、索引类型为 String 的默认索引属性。

参数 [JScript]

index
要获得或设置的元素从零开始的索引。

参数 [Visual Basic, C#, C++]

index
要获得或设置的元素从零开始的索引。

属性值

指定索引处的元素。

异常

异常类型 条件
ArgumentOutOfRangeException index 不是 IList 中的有效索引。
NotSupportedException 设置该属性,而且 IList 为只读。

备注

通过使用下面的语法,此属性提供访问集合中特定元素的能力:myCollection[index]

要求

平台: Windows 98, Windows NT 4.0, Windows ME, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 系列, 公共语言基础结构 (CLI) 标准

请参见

IList 接口 | IList 成员 | System.Collections 命名空间

posted @ 2007-05-24 17:01  四两  阅读(336)  评论(0编辑  收藏  举报
加油,哥们,现在开始!