Share via


Imports.Remove(Object) Method

Definition

Removes an imports statement from the Imports collection. The imports statement to be removed may be indexed by either the string specifying the import or by a one-based index.

public:
 void Remove(System::Object ^ index);
public:
 void Remove(Platform::Object ^ index);
void Remove(winrt::Windows::Foundation::IInspectable const & index);
[System.Runtime.InteropServices.DispId(6)]
public void Remove (object index);
[<System.Runtime.InteropServices.DispId(6)>]
abstract member Remove : obj -> unit
Public Sub Remove (index As Object)

Parameters

index
Object

Required. Either a one-based index into the collection, or the imports statement string to remove.

Attributes

Examples

' Macro Editor  
Imports VSLangProj  
Public Sub RemoveImport()  
   ' Project must be a Visual Basic project.  
   Try  
      Dim vsproject As VSProject = _  
         CType(DTE.Solution.Projects.Item(1).Object, VSProject)  
      vsproject.Imports.Remove("SomeAlias = SomeNamespace.*")  
      vsproject.Imports.Remove(1)  
   Catch e As System.Exception  
      MsgBox(e.Message)  
   End Try  
End Sub  

Remarks

An error is generated if the imports statement does not exist in the collection. If you use a string index, the string must be an exact match for the imports statement. For example, an index of "SomeNamespace" will not remove the imports statement "SomeNamespace.*".

Applies to