次の方法で共有


ImportCollection.IndexOf メソッド

指定した Import を検索し、コレクション内で最初に見つかった位置の 0 から始まるインデックス番号を返します。

Public Function IndexOf( _
   ByVal import As Import _) As Integer
[C#]
public int IndexOf(Importimport);
[C++]
public: int IndexOf(Import* import);
[JScript]
public function IndexOf(
   import : Import) : int;

パラメータ

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

戻り値

32 ビット符号付き整数。

使用例

[Visual Basic, C#, C++] IndexOf メソッドを使用する例を次に示します。

 
' Get Import by Index.
Dim myImport As Import = _
      myServiceDescription.Imports(myServiceDescription.Imports.Count - 1)
Console.WriteLine("Import by Index...")
If myImportCollection.Contains(myImport) Then
   Console.WriteLine("Import Namespace '" + myImport.Namespace + _
                     "' is found in 'ImportCollection'.")
   Console.WriteLine("Index of '" + myImport.Namespace + _
                     "' in 'ImportCollection' = " + _
                     myImportCollection.IndexOf(myImport).ToString())
   Console.WriteLine("Delete Import from 'ImportCollection'...")
   myImportCollection.Remove(myImport)
   If myImportCollection.IndexOf(myImport) = - 1 Then
      Console.WriteLine("Import is successfully removed from Import Collection.")
   End If

[C#] 
// Get Import by Index.
Import myImport = myServiceDescription.Imports[myServiceDescription.Imports.Count-1];
Console.WriteLine("Import by Index...");
if (myImportCollection.Contains(myImport))
{
   Console.WriteLine("Import Namespace '"
            + myImport.Namespace + "' is found in 'ImportCollection'.");
   Console.WriteLine("Index of '" + myImport.Namespace + "' in 'ImportCollection' = "
                                             + myImportCollection.IndexOf(myImport));
   Console.WriteLine("Deleting Import from 'ImportCollection'...");
   myImportCollection.Remove(myImport);
   if(myImportCollection.IndexOf(myImport) == -1)
      Console.WriteLine("Import is successfully removed from Import Collection.");
}

[C++] 
// Get Import by Index.
Import * myImport = myServiceDescription->Imports->Item[myServiceDescription->Imports->Count-1];
Console::WriteLine(S"Import by Index...");
if (myImportCollection->Contains(myImport))
{
   Console::WriteLine(S"Import Namespace ' {0} ' is found in 'ImportCollection'.", myImport -> Namespace);
   Console::WriteLine(S"Index of '{0}' in 'ImportCollection' = {1}", myImport -> Namespace, __box(myImportCollection->IndexOf(myImport)));
   Console::WriteLine(S"Deleting Import from 'ImportCollection'...");
   myImportCollection->Remove(myImport);
   if (myImportCollection->IndexOf(myImport) == -1)
      Console::WriteLine(S"Import is successfully removed from Import Collection.");
}

[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 ファミリ

参照

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