DtsProperties.Item[Object] 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
從集合中回傳一個 DtsProperty 物件。
public:
property Microsoft::SqlServer::Dts::Runtime::DtsProperty ^ default[System::Object ^] { Microsoft::SqlServer::Dts::Runtime::DtsProperty ^ get(System::Object ^ index); };
public Microsoft.SqlServer.Dts.Runtime.DtsProperty this[object index] { get; }
member this.Item(obj) : Microsoft.SqlServer.Dts.Runtime.DtsProperty
Default Public ReadOnly Property Item(index As Object) As DtsProperty
參數
- index
- Object
要回傳物件的 DtsProperty 名稱、索引或身份。
屬性值
DtsProperty 物件。
範例
以下程式碼範例是透過語 DtsProperties[x] 法取得集合中第五個物件名稱,從集合中取得一個項目。
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlServer.Dts.Runtime;
namespace DtsProperties_API
{
class Program
{
static void Main(string[] args)
{
Package pkg = new Package();
// Get the Properties collection from the package.
// This shows the default properties set on new packages.
DtsProperties pkgProperties = pkg.Properties;
// Create the enumerator.
PropertyEnumerator myEnumerator = pkgProperties.GetEnumerator();
// Show the use of the Contains method.
Boolean containsCertObj = pkgProperties.Contains("CertificateObject");
Console.WriteLine("Contains CertificateObject? {0}", containsCertObj);
// Show the use of the item[x] syntax.
String aName = pkgProperties[5].Name;
Console.WriteLine("Property 5 is {0}", aName);
// Show the use of the MoveNext and Current methods.
int i = 0;
while ((myEnumerator.MoveNext()) && (myEnumerator.Current != null))
{
Console.WriteLine("[{0}] {1}", i++, myEnumerator.Current.Name);
}
}
}
}
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Microsoft.SqlServer.Dts.Runtime
Namespace DtsProperties_API
Class Program
Shared Sub Main(ByVal args() As String)
Dim pkg As Package = New Package()
' Get the Properties collection from the package.
' This shows the default properties set on new packages.
Dim pkgProperties As DtsProperties = pkg.Properties
' Create the enumerator.
Dim myEnumerator As PropertyEnumerator = pkgProperties.GetEnumerator()
' Show the use of the Contains method.
Dim containsCertObj As Boolean = pkgProperties.Contains("CertificateObject")
Console.WriteLine("Contains CertificateObject? {0}", containsCertObj)
' Show the use of the item[x] syntax.
Dim aName As String = pkgProperties(5).Name
Console.WriteLine("Property 5 is {0}", aName)
' Show the use of the MoveNext and Current methods.
Dim i As Integer = 0
While (myEnumerator.MoveNext()) &&(myEnumerator.Current <> Nothing)
Console.WriteLine("[{0}] {1}",i = Console.WriteLine("[{0}] {1}",i + 1
End While
End Sub
End Class
End Namespace
範例輸出:
包含 CertificateObject? 沒錯
屬性 5 是配置
[0] 憑證上下文
[1] 憑證物件
[2] 檢查點檔案名稱
[3] 檢查點使用
[4] CheckSignatureOnLoad
[5] 配置
[6] 連結
[7] 創世日期
[8] 創世名稱
[9] 創造者電腦名稱
[10] 創造者名
[11] 延遲驗證
. . .
[63] 版本指南
[64] 版本大
[65] 版本次要
[66] 警告
備註
如果呼叫方法 Contains 返回 true,你可以使用語法 DtsProperties[index]來存取集合中指定的元素。 若 Contains 方法返回 false,則會拋出例外。 在 C# 中,這個屬性就是類別的 DtsProperties 索引器。