This documentation is archived and is not being maintained.

ImportCollection.Remove Method

Removes the first occurrence of the specified Import from the ImportCollection.

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

Parameters

import
The Import to remove from the collection.

Remarks

This method performs a linear search; therefore, the average execution time is proportional to Count.

The elements that follow the removed Import move up to occupy the vacated spot.

Example

[Visual Basic, C#, C++] The following example demonstrates the use of the Remove method.

[Visual Basic] 
' 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] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

ImportCollection Class | ImportCollection Members | System.Web.Services.Description Namespace

Show: