Linguaggio

ConnectionInfos.Item[Object] Proprietà

Definizione

Recupera l'oggetto ConnectionInfo dalla collezione tramite nome, indice, ID o identità.

public:
 property Microsoft::SqlServer::Dts::Runtime::ConnectionInfo ^ default[System::Object ^] { Microsoft::SqlServer::Dts::Runtime::ConnectionInfo ^ get(System::Object ^ index); };
public Microsoft.SqlServer.Dts.Runtime.ConnectionInfo this[object index] { get; }
member this.Item(obj) : Microsoft.SqlServer.Dts.Runtime.ConnectionInfo
Default Public ReadOnly Property Item(index As Object) As ConnectionInfo

Parametri

index
Object

Il nome, indice, ID o identità dell'oggetto nella collezione da restituire.

Valore della proprietà

Un ConnectionInfo oggetto della collezione che corrisponde al nome, indice, ID o identità indicato nel index parametro.

Esempio

Il seguente esempio di codice recupera un elemento dalla collezione utilizzando due metodi. Il primo metodo utilizza la connectionInfos[0] sintassi per recuperare l'intero oggetto, situato nella prima posizione della collezione, e poi lo colloca nell'oggetto connInfo . Ora puoi recuperare tutte le proprietà dall'oggetto ConnectionInfo come al solito. Il secondo metodo recupera una proprietà specifica dal primo oggetto della collezione.

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

namespace ConnectionInfos_GetEnum  
{  
    class Program  
    {  
        static void Main(string[] args)  
        {  
            Application dtsApplication = new Application();  
            ConnectionInfos connectionInfos = dtsApplication.ConnectionInfos;  

            //Using the Item method syntax of [x], obtain the first entry and a name.  
            ConnectionInfo connInfo = connectionInfos[0];  
            String nameOfFirstItem = connectionInfos[0].Name;  

            //Print the name of the log provider object located at position [0].  
            Console.WriteLine("The ID of the first connection info is: {0}", connInfo.ID);  
            Console.WriteLine("The Name of the first connection info is: {0}", nameOfFirstItem);  

        }  
    }  
}  
Imports System  
Imports System.Collections.Generic  
Imports System.Text  
Imports Microsoft.SqlServer.Dts.Runtime  

Namespace ConnectionInfos_GetEnum  
    Class Program  
        Shared  Sub Main(ByVal args() As String)  
            Dim dtsApplication As Application =  New Application()   
            Dim connectionInfos As ConnectionInfos =  dtsApplication.ConnectionInfos   

            'Using the Item method syntax of [x], obtain the first entry and a name.  
            Dim connInfo As ConnectionInfo =  connectionInfos(0)   
            Dim nameOfFirstItem As String =  connectionInfos(0).Name   

            'Print the name of the log provider object located at position [0].  
            Console.WriteLine("The ID of the first connection info is: {0}", connInfo.ID)  
            Console.WriteLine("The Name of the first connection info is: {0}", nameOfFirstItem)  

        End Sub  
    End Class  
End Namespace  

Output di esempio:

The ID of the first connection info is: {41F5EFE4-E91A-4EB0-BF10-D40FD48B3C03}

The Name of the first connection info is: DTS Connection Manager for Files

Commenti

Se una chiamata al Contains metodo restituisce true, puoi accedere all'elemento specificato nella collezione usando la sintassi ConnectionInfos[index]. Se il Contains metodo restituisce false, questa proprietà crea un'eccezione. In C# questa proprietà è l'indicizzatore per la ConnectionInfos classe .

Si applica a