DbConnectionStringBuilder.Count DbConnectionStringBuilder.Count DbConnectionStringBuilder.Count DbConnectionStringBuilder.Count Property

定義

ConnectionString プロパティ内に含まれる現在のキー数を取得します。Gets the current number of keys that are contained within the ConnectionString property.

public:
 virtual property int Count { int get(); };
[System.ComponentModel.Browsable(false)]
public virtual int Count { get; }
member this.Count : int
Public Overridable ReadOnly Property Count As Integer

プロパティ値

DbConnectionStringBuilder インスタンスで保守されている接続文字列内に含まれるキーの数。The number of keys that are contained within the connection string maintained by the DbConnectionStringBuilder instance.

実装

次の例は、 CountプロパティConnectionStringの内容を変更する前と後の両方のプロパティを示しています。The following example demonstrates the Count property both before and after you modify the contents of the ConnectionString property.

static void Main()
{
    DbConnectionStringBuilder builder = new DbConnectionStringBuilder();
    builder.ConnectionString =
        "Data Source=(local);Initial Catalog=AdventureWorks;" +
        "Integrated Security=SSPI";

    // This should display "3" in the console window.
    Console.WriteLine("Original count: " + builder.Count);

    builder.Add("Connection Timeout", 25);

    // This should display the new connection string and
    // the number of items (4) in the console window.
    Console.WriteLine(builder.ConnectionString);
    Console.WriteLine("New count: " + builder.Count);

    Console.WriteLine();
    Console.WriteLine("Press Enter to finish.");
    Console.ReadLine();
}
Sub Main()
    Dim builder As New DbConnectionStringBuilder
    builder.ConnectionString = _
        "Data Source=(local);Initial Catalog=AdventureWorks;" & _
        "Integrated Security=SSPI"

    ' This should display "3" in the console window.
    Console.WriteLine(builder.Count)

    builder.Add("Connection Timeout", 25)

    ' This should display the new connection string and
    ' the number of items (4) in the console window.
    Console.WriteLine(builder.ConnectionString)
    Console.WriteLine(builder.Count)

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

適用対象

こちらもご覧ください