다음을 통해 공유


SqlConnectionStringBuilder.Keys 속성

정의

ICollection 있는 키가 들어 있는 SqlConnectionStringBuilder키를 가져옵니다.

public:
 virtual property System::Collections::ICollection ^ Keys { System::Collections::ICollection ^ get(); };
public override System.Collections.ICollection Keys { get; }
member this.Keys : System.Collections.ICollection
Public Overrides ReadOnly Property Keys As ICollection

속성 값

ICollection 에 있는 키를 포함하는 입니다SqlConnectionStringBuilder.

예제

다음 콘솔 애플리케이션 예제에서는 새 SqlConnectionStringBuilder. 코드는 키/값 쌍을 표시하는 속성에서 Keys 반환된 루프를 반복 ICollection 합니다.

using System.Data.SqlClient;

class Program
{
    static void Main()
    {
        SqlConnectionStringBuilder builder =
            new SqlConnectionStringBuilder();
        builder.DataSource = "(local)";
        builder.IntegratedSecurity = true;
        builder.InitialCatalog = "AdventureWorks";

        // Loop through the collection of keys, displaying
        // the key and value for each item:
        foreach (string key in builder.Keys)
            Console.WriteLine("{0}={1}", key, builder[key]);

        Console.WriteLine();
        Console.WriteLine("Press Enter to continue.");
        Console.ReadLine();
    }
}
Imports System.Data.SqlClient

Module Module1
    Sub Main()
        Dim builder As New SqlConnectionStringBuilder
        builder.DataSource = "(local)"
        builder.IntegratedSecurity = True
        builder.InitialCatalog = "AdventureWorks"

        ' Loop through the collection of keys, displaying 
        ' the key and value for each item.
        For Each key As String In builder.Keys
            Console.WriteLine("{0}={1}", key, builder(key))
        Next

        Console.WriteLine()
        Console.WriteLine("Press Enter to continue.")
        Console.ReadLine()
    End Sub
End Module

설명

ICollection 의 순서는 지정되지 않지만 속성에서 반환 Values 된 연결된 값 ICollection 과 동일한 순서입니다.

적용 대상

추가 정보