Executables.Contains(Object) Executables.Contains(Object) Executables.Contains(Object) Executables.Contains(Object) Method


Indicates whether the items in the collection can be accessed using the index as the parameter.

 bool Contains(System::Object ^ index);
public bool Contains (object index);
member this.Contains : obj -> bool
Public Function Contains (index As Object) As Boolean


Object Object Object Object

The index of the Executable object.


true if you can retrieve an item using the syntax Executables[index]; false if indexing cannot be used to retrieve items from the Executables collection.


The following code example adds the Bulk Insert task as an executable, then uses Contains to verify the existance of at least one executable in the package.

using System;  
using System.Collections.Generic;  
using System.Text;  
using Microsoft.SqlServer.Dts.Runtime;  
namespace Executables_API  
        class Program  
        static void Main(string[] args)  
            Package pkg = new Package();  
            Executable exec = pkg.Executables.Add("STOCK:BulkInsertTask");  
            // Obtain the collection.  
            Executables pgkExecs = pkg.Executables;  
            foreach (Executable eachExec in pgkExecs)  
                TaskHost th = exec as TaskHost;  
                Console.WriteLine("Executable creation name is: {0}", th.CreationName);  
            // Show use of Contains.  
            if (pgkExecs.Contains(0))  
                Console.WriteLine("Contains returned true");  
                Console.WriteLine("Contains returned false");  
Imports System  
Imports System.Collections.Generic  
Imports System.Text  
Imports Microsoft.SqlServer.Dts.Runtime  
Namespace Executables_API  
        Class Program  
        Shared  Sub Main(ByVal args() As String)  
            Dim pkg As Package =  New Package()   
            Dim exec As Executable =  pkg.Executables.Add("STOCK:BulkInsertTask")   
            ' Obtain the collection.  
            Dim pgkExecs As Executables =  pkg.Executables   
            Dim eachExec As Executable  
            For Each eachExec In pgkExecs  
                Dim th As TaskHost =  exec as TaskHost   
                Console.WriteLine("Executable creation name is: {0}", th.CreationName)  
            ' Show use of Contains.  
            If pgkExecs.Contains(0) Then  
                Console.WriteLine("Contains returned true")  
                Console.WriteLine("Contains returned false")  
            End If  
        End Sub  
        End Class  
End Namespace  

Sample Output:

Executable creation name is: Microsoft.SqlServer.Dts.Tasks.BulkInsertTask.BulkInsertTask, Microsoft.SqlServer.BulkInsertTask, Version=, Culture=neutral, PublicKeyToken=89845dcd8080cc91

Contains returned true

Applies to