CodeDirectiveCollection.IndexOf(CodeDirective) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取指定 CodeDirective 对象的集合中的索引(如果该索引存在于集合中)。
public:
int IndexOf(System::CodeDom::CodeDirective ^ value);
public int IndexOf(System.CodeDom.CodeDirective value);
member this.IndexOf : System.CodeDom.CodeDirective -> int
Public Function IndexOf (value As CodeDirective) As Integer
参数
- value
- CodeDirective
要 CodeDirective 定位在集合中的对象。
返回
指定对象的集合中的索引位置(如果找到);否则为 -1。
示例
下面的代码示例演示如何使用 IndexOf 该方法获取指定 CodeDirective 对象的集合中的索引。 此示例是CodeDirectiveCollection类所提供的一个大型示例的一部分。
// Tests for the presence of a CodeDirective in the
// collection, and retrieves its index if it is found.
CodeDirective testDirective = new CodeRegionDirective(CodeRegionMode.Start, "Region1");
int itemIndex = -1;
if (collection.Contains(testDirective))
itemIndex = collection.IndexOf(testDirective);
' Tests for the presence of a CodeDirective in the
' collection, and retrieves its index if it is found.
Dim testDirective = New CodeRegionDirective(CodeRegionMode.Start, "Region1")
Dim itemIndex As Integer = -1
If collection.Contains(testDirective) Then
itemIndex = collection.IndexOf(testDirective)
End If