InstallerCollection.Contains Method (Installer)


Determines whether the specified installer is included in collection.

Namespace:   System.Configuration.Install
Assembly:  System.Configuration.Install (in System.Configuration.Install.dll)

public bool Contains(
	Installer value


Type: System.Configuration.Install.Installer

An Installer that represents the installer to look for.

Return Value

Type: System.Boolean

true if the specified installer is in this collection; otherwise, false.

The following example demonstrates the Remove method, Contains method, and IndexOf method of the InstallerCollection class. It creates AssemblyInstaller instances for MyAssembly1.exe and MyAssembly2.exe. These instances are added to a TransactedInstaller. MyAssembly2.exe is then removed from the InstallerCollection of the TransactedInstaller. The installation process starts and installs only MyAssembly1.exe.

TransactedInstaller myTransactedInstaller = new TransactedInstaller();
AssemblyInstaller myAssemblyInstaller1;
AssemblyInstaller myAssemblyInstaller2;
InstallContext myInstallContext;

// Create a instance of 'AssemblyInstaller' that installs 'MyAssembly1.exe'.
myAssemblyInstaller1 = 
   new AssemblyInstaller("MyAssembly1.exe", null);

// Add the instance of 'AssemblyInstaller' to the 'TransactedInstaller'.
myTransactedInstaller.Installers.Insert(0, myAssemblyInstaller1);

// Create a instance of 'AssemblyInstaller' that installs 'MyAssembly2.exe'.
myAssemblyInstaller2 = 
   new AssemblyInstaller("MyAssembly2.exe", null);

// Add the instance of 'AssemblyInstaller' to the 'TransactedInstaller'.
myTransactedInstaller.Installers.Insert(1, myAssemblyInstaller2);

// Remove the 'myAssemblyInstaller2' from the 'Installers' collection.
   Console.WriteLine("\nInstaller at index : {0} is being removed",

.NET Framework
Available since 1.1
Return to top