Share via


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。

适用于

另请参阅