LogEntryInfos.Contains(Object) 方法

定义

指示是否可以通过使用索引访问集合中的项而不引发异常。

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

参数

index
Object

要在集合中查找的 LogEntryInfo 对象的名称、说明、ID 或索引。

返回

一个布尔值,指示是否可以按名称、说明、ID 或索引访问集合。 true 值指示可以使用语法 LogEntryInfos[index] 访问集合。 false 值指示索引不能用于从 LogEntryInfos 集合中检索项;使用此属性引发异常。

示例

下面的代码示例使用 Contains 该方法来确定名称为“Diagnostic”的日志条目是否在集合中。 该方法返回一个 Boolean.

using System;  
using System.Collections.Generic;  
using System.Text;  
using Microsoft.SqlServer.Dts.Runtime;  

namespace LogEntryInfosTest  
{  
    class Program  
    {  
        static void Main(string[] args)  
        {  
            // The package is one of the SSIS Samples.  
            string mySample = @"C:\Program Files\Microsoft SQL Server\100\Samples\Integration Services\Package Samples\CalculatedColumns Sample\CalculatedColumns\CalculatedColumns.dtsx";  

            // Create the Application, and load the sample.  
            Application app = new Application();  
            Package pkg = app.LoadPackage(mySample, null);  

            // Get the LogEntryInfos from the package.  
            LogEntryInfos logInfos = pkg.LogEntryInfos;  

            //See if the collection contains a LogEntryInfo named "Diagnostic".  
            Boolean logDiagnostic = logInfos.Contains("Diagnostic");  
            Console.WriteLine("Contains Diagnostic? {0}", logDiagnostic);  

            Console.WriteLine();  
        }  
    }  
}  
Imports System  
Imports System.Collections.Generic  
Imports System.Text  
Imports Microsoft.SqlServer.Dts.Runtime  

Namespace LogEnTryInfosTest  
    Class Program  
        Shared  Sub Main(ByVal args() As String)  
            ' The package is one of the SSIS Samples.  
            Dim mySample As String =  "C:\Program Files\Microsoft SQL Server\100\Samples\Integration Services\Package Samples\CalculatedColumns Sample\CalculatedColumns\CalculatedColumns.dtsx"   

            ' Create the Application, and load the sample.  
            Dim app As Application =  New Application()   
            Dim pkg As Package =  app.LoadPackage(mySample,Nothing)   

            ' Get the LogEntryInfos from the package.  
            Dim logInfos As LogEnTryInfos =  pkg.LogEnTryInfos   

            'See if the collection contains a LogEntryInfo named "Diagnostic".  
            Dim logDiagnostic As Boolean =  logInfos.Contains("Diagnostic")   
            Console.WriteLine("Contains Diagnostic? {0}", logDiagnostic)  

            Console.WriteLine()  
        End Sub  
    End Class  
End Namespace  

示例输出:

包含诊断? True

适用于