语言

ProfileSettingsCollection.IndexOf(String) 方法

定义

返回指定 ProfileSettings 对象的索引。

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

集合中对象的名称 ProfileSettings 。

返回

指定 ProfileSettings 对象的索引;如果未在集合中找到该对象,则 -1。

示例

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

// Get the index of the 'Default' ProfileSettings in the Profiles collection property.
Console.WriteLine("Profiles index for 'Default': {0}.",
    healthMonitoringSection.Profiles.IndexOf("Default"));
' Get the index of the 'Default' ProfileSettings in the Profiles collection property.
Console.WriteLine("Profiles index for 'Default': {0}.", _
    healthMonitoringSection.Profiles.IndexOf("Default"))

适用于

另请参阅