次の方法で共有


ServiceCollection.IndexOf メソッド

指定した Service を検索し、 ServiceCollection 内でその文字列が最初に見つかった位置の 0 から始まるインデックス番号を返します。

Public Function IndexOf( _
   ByVal service As Service _) As Integer
[C#]
public int IndexOf(Serviceservice);
[C++]
public: int IndexOf(Service* service);
[JScript]
public function IndexOf(
   service : Service) : int;

パラメータ

  • service
    コレクション内での検索対象となる Service

戻り値

32 ビット符号付き整数。

使用例

 
If myServiceDescription.Services.Contains(myService) Then
   Console.WriteLine( _
      "The mentioned service Exists at index {0} in the WSDL.", _
      myServiceDescription.Services.IndexOf(myService))
   Dim myServiceArray(myServiceDescription.Services.Count - 1) _
   As Service

   ' Copy the services into an array.
   myServiceDescription.Services.CopyTo(myServiceArray, 0)
   Dim myEnumerator As IEnumerator = myServiceArray.GetEnumerator()
   Console.WriteLine("The names of services in the array are")
   While myEnumerator.MoveNext()
      Dim myService1 As Service = CType(myEnumerator.Current, Service)
      Console.WriteLine(myService1.Name)
   End While
Else
   Console.WriteLine("Service does not exist in the WSDL.")
End If

[C#] 
if(myServiceDescription.Services.Contains(myService))
{
   Console.WriteLine(
      "The mentioned service exists at index {0} in the WSDL.",
      myServiceDescription.Services.IndexOf(myService));
   Service[] myServiceArray =
      new Service[myServiceDescription.Services.Count];

   // Copy the services into an array.
   myServiceDescription.Services.CopyTo(myServiceArray,0);
   IEnumerator myEnumerator = myServiceArray.GetEnumerator();
   Console.WriteLine("The names of services in the array are");
   while(myEnumerator.MoveNext())
   {
      Service myService1 = (Service)myEnumerator.Current;
      Console.WriteLine(myService1.Name);
   }
}
else
{
   Console.WriteLine("Service does not exist in the WSDL." );
}

[C++] 
if(myServiceDescription->Services->Contains(myService))
{
   Console::WriteLine(
      S"The mentioned service exists at index {0} in the WSDL.",
      __box(myServiceDescription->Services->IndexOf(myService)));
   Service* myServiceArray[] =
      new Service*[myServiceDescription->Services->Count];

   // Copy the services into an array.
   myServiceDescription->Services->CopyTo(myServiceArray,0);
   IEnumerator* myEnumerator = myServiceArray->GetEnumerator();
   Console::WriteLine(S"The names of services in the array are");
   while(myEnumerator->MoveNext())
   {
      Service* myService1 = dynamic_cast<Service*>(myEnumerator->Current);
      Console::WriteLine(myService1->Name);
   }
}
else
{
   Console::WriteLine(S"Service does not exist in the WSDL." );
}

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

ServiceCollection クラス | ServiceCollection メンバ | System.Web.Services.Description 名前空間