共用方式為


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。

適用於

另請參閱