次の方法で共有


ImportCollection.Remove メソッド

ImportCollection から、最初に出現する指定した Import を削除します。

Public Sub Remove( _
   ByVal import As Import _)
[C#]
public void Remove(Importimport);
[C++]
public: void Remove(Import* import);
[JScript]
public function Remove(
   import : Import);

パラメータ

  • import
    コレクションから削除する Import

解説

このメソッドはリニア サーチを実行します。したがって、平均検索時間は Count に比例します。

削除された Import の後ろにある要素は、前にずれて空白になった場所に移動します。

使用例

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

 
' 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 名前空間