Bagikan melalui


DbConnectionStringBuilder.Count Properti

Definisi

Mendapatkan jumlah kunci saat ini yang terkandung dalam ConnectionString properti .

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

Nilai Properti

Jumlah kunci yang terkandung dalam string koneksi yang dikelola oleh DbConnectionStringBuilder instans.

Penerapan

Atribut

Contoh

Contoh berikut menunjukkan Count properti baik sebelum dan sesudah Anda memodifikasi konten ConnectionString properti.

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

Berlaku untuk

Lihat juga