语言

RuleSettingsCollection.IndexOf(String) 方法

定义

查找集合中具有指定名称的对象索引 RuleSettings 。

public:
 int IndexOf(System::String ^ name);
public int IndexOf(string name);
member this.IndexOf : string -> int
Public Function IndexOf (name As String) As Integer

参数

name
String

集合中对象的名称 RuleSettings 。

返回

集合中具有指定名称的对象索引 RuleSettings 。

示例

下面的代码示例演示如何使用 IndexOf 该方法。 该代码示例是 HealthMonitoringSection 类中的一个较大示例的一部分。

// Get the index of the 'All Errors Default' RuleSettings in the Rules collection property.
Console.WriteLine("EventMappings index for 'All Errors Default': {0}.",
    healthMonitoringSection.Rules.IndexOf("All Errors Default"));
' Get the index of the 'All Errors Default' RuleSettings in the Rules collection property.
Console.WriteLine("EventMappings index for 'All Errors Default': {0}.", _
    healthMonitoringSection.Rules.IndexOf("All Errors Default"))

注解

如果 RuleSettings 具有指定名称的对象不在集合中,则返回 -1。

适用于

另请参阅