DataTypeInfos.Item[Object] Propriété
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Retourne un objet DataTypeInfo à partir de la collection.
public:
property Microsoft::SqlServer::Dts::Runtime::DataTypeInfo ^ default[System::Object ^] { Microsoft::SqlServer::Dts::Runtime::DataTypeInfo ^ get(System::Object ^ index); };
public Microsoft.SqlServer.Dts.Runtime.DataTypeInfo this[object index] { get; }
member this.Item(obj) : Microsoft.SqlServer.Dts.Runtime.DataTypeInfo
Default Public ReadOnly Property Item(index As Object) As DataTypeInfo
Paramètres
- index
- Object
Index de l'objet DataTypeInfo à extraire de la collection.
Valeur de propriété
Objet DataTypeInfo.
Exemples
L’exemple de code suivant récupère un élément de la collection à l’aide de deux méthodes. La première méthode utilise la dataInfos[0]
syntaxe pour récupérer l’objet entier situé à la première position de la collection et le placer dans l’objet dtInfo
. Une fois cette opération effectuée, vous pouvez récupérer toutes les propriétés de l’objet comme d’habitude dtInfo
. La deuxième méthode montre comment récupérer une propriété spécifique à partir du premier objet de la collection.
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlServer.Dts.Runtime;
namespace DataTypeInfos_GetEnum_Current
{
class Program
{
static void Main(string[] args)
{
//Create the DataTypeInfos collection.
DataTypeInfos dataInfos = new Application().DataTypeInfos;
//Using the Item method syntax of [x], obtain the first entry.
DataTypeInfo dtInfo = dataInfos[0];
String nameOfFirstItem = dataInfos[0].TypeName;
//Print the name of the task object located at position [0].
Console.WriteLine("The TypeEnumName of the first item is: {0}", dtInfo.TypeEnumName);
Console.WriteLine("The TypeName of the first task is: {0}", nameOfFirstItem);
}
}
}
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Microsoft.SqlServer.Dts.Runtime
Namespace DataTypeInfos_GetEnum_Current
Class Program
Shared Sub Main(ByVal args() As String)
'Create the DataTypeInfos collection.
Dim dataInfos As DataTypeInfos = New Application().DataTypeInfos
'Using the Item method syntax of [x], obtain the first entry.
Dim dtInfo As DataTypeInfo = dataInfos(0)
Dim nameOfFirstItem As String = dataInfos(0).TypeName
'Print the name of the task object located at position [0].
Console.WriteLine("The TypeEnumName of the first item is: {0}", dtInfo.TypeEnumName)
Console.WriteLine("The TypeName of the first task is: {0}", nameOfFirstItem)
End Sub
End Class
End Namespace
Exemple de sortie :
TypeEnumName du premier élément est : DT_R4
TypeName de la première tâche : float
Remarques
Si l’appel à la Contains méthode retourne true
, vous pouvez accéder à l’élément spécifié dans la collection à l’aide de la syntaxe DataTupeInfos[index]
. Si la Contains méthode est retournée false
, cette propriété lève une exception. En C#, cette propriété est l'indexeur correspondant à la classe DataTypeInfos.