ConnectionInfos.Item[Object] 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
按名称、索引、ID 或标识从集合中检索 ConnectionInfo 对象。
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
参数
- index
- Object
集合中要返回的对象的名称、索引、ID 或标识。
属性值
一个来自集合的 ConnectionInfo 对象,该对象与在 index
参数中给定的名称、索引、ID 或标识匹配。
示例
下面的代码示例使用两种方法从集合中检索项。 第一种方法使用 connectionInfos[0]
语法检索整个对象,该对象位于集合的第一个位置,然后将其置于对象中 connInfo
。 现在可以像往常一样从 ConnectionInfo
对象中检索所有属性。 第二种方法从集合中的第一个对象检索特定属性。
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
示例输出:
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
注解
如果调用 Contains 该方法返回 true
,则可以使用语法 ConnectionInfos[index]
访问集合中的指定元素。
Contains如果该方法返回false
,此属性将引发异常。 在 C# 中,此属性是 ConnectionInfos 类的索引器。