DbConnectionStringBuilder.Keys 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
에 ICollection 있는 키가 들어 있는 DbConnectionStringBuilder키를 가져옵니다.
public:
virtual property System::Collections::ICollection ^ Keys { System::Collections::ICollection ^ get(); };
public virtual System.Collections.ICollection Keys { get; }
[System.ComponentModel.Browsable(false)]
public virtual System.Collections.ICollection Keys { get; }
member this.Keys : System.Collections.ICollection
[<System.ComponentModel.Browsable(false)>]
member this.Keys : System.Collections.ICollection
Public Overridable ReadOnly Property Keys As ICollection
속성 값
ICollection 에 있는 키를 포함하는 입니다DbConnectionStringBuilder.
구현
- 특성
예제
다음 콘솔 애플리케이션 예제에서는 새 DbConnectionStringBuilder키를 만들고 일부 키를 추가합니다. 코드 ICollection 는 키/값 쌍을 표시하는 속성에서 Keys 반환된 루프를 반복한 다음 새 키를 추가합니다. 속성이 Keys 동적 ICollection을 반환하므로 두 번째 루프는 최신 항목을 포함하여 모든 키/값 쌍을 표시합니다.
static void Main()
{
DbConnectionStringBuilder builder = new
DbConnectionStringBuilder();
builder["Data Source"] = "(local)";
builder["Integrated Security"] = true;
builder["Initial Catalog"] = "AdventureWorks";
// Obtain reference to the collection of keys.
ICollection keys = builder.Keys;
Console.WriteLine("Keys before adding TimeOut:");
foreach (string key in keys)
Console.WriteLine("{0}={1}", key, builder[key]);
// Add a new item to the collection.
builder["Timeout"] = 300;
Console.WriteLine();
Console.WriteLine("Keys after adding TimeOut:");
// Because the Keys property is dynamically updated,
// the following loop includes the Timeout key.
foreach (string key in keys)
Console.WriteLine("{0}={1}", key, builder[key]);
Console.WriteLine();
Console.WriteLine("Press Enter to continue.");
Console.ReadLine();
}
Sub Main()
Dim builder As New DbConnectionStringBuilder
builder("Data Source") = "(local)"
builder("integrated security") = True
builder("Initial Catalog") = "AdventureWorks;NewValue=Bad"
' Obtain reference to the collection of keys.
Dim keys As ICollection = builder.Keys
Console.WriteLine("Keys before adding TimeOut:")
For Each key As String In keys
Console.WriteLine("{0}={1}", key, builder(key))
Next
' Add a new item to the collection.
builder("Timeout") = 300
Console.WriteLine()
Console.WriteLine("Keys after adding TimeOut:")
' Because the Keys property is dynamically updated,
' the following loop includes the Timeout key.
For Each key As String In keys
Console.WriteLine("{0}={1}", key, builder(key))
Next
Console.WriteLine()
Console.WriteLine("Press Enter to continue.")
Console.ReadLine()
End Sub
설명
값 ICollection 의 순서는 지정되지 않지만 속성에서 반환 Values 된 연결된 값 ICollection 과 동일한 순서입니다.
반환 ICollection 된 복사본은 정적 복사본 ICollection 이 아니라 원래 DbConnectionStringBuilder의 키를 다시 참조합니다. 따라서 변경 내용이 DbConnectionStringBuilder .에 ICollection반영됩니다.