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 索引器。