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 を返します。

適用対象

こちらもご覧ください