共用方式為


OracleConnectionStringBuilder.ContainsKey(String) 方法

定義

判斷 OracleConnectionStringBuilder 是否包含特定索引鍵。

public:
 override bool ContainsKey(System::String ^ keyword);
public override bool ContainsKey (string keyword);
override this.ContainsKey : string -> bool
Public Overrides Function ContainsKey (keyword As String) As Boolean

參數

keyword
String

要在 OracleConnectionStringBuilder 中尋找的索引鍵。

傳回

如果 OracleConnectionStringBuilder 包含具有指定索引鍵的項目,則為 true,否則為 false

例外狀況

keyword 為 null (在 Visual Basic 中為 Nothing)。

範例

下列範例會 OracleConnectionStringBuilder 建立 實例、設定它的一些屬性,然後藉由呼叫 ContainsKey 方法來嘗試判斷物件中是否有各種索引鍵。

OracleConnectionStringBuilder builder =
    new(GetConnectionString());
Console.WriteLine($"Connection string = '{builder.ConnectionString}'");

// Keys you've provided return true.
Console.WriteLine(builder.ContainsKey("Integrated Security"));

// Keys that are valid but have not been set return true.
Console.WriteLine(builder.ContainsKey("Unicode"));

// Keys that do not exist return false.
Console.WriteLine(builder.ContainsKey("MyKey"));
Sub Main()
    Dim builder As _
 New OracleConnectionStringBuilder(GetConnectionString())
    Console.WriteLine("Connection string = " & builder.ConnectionString)

    ' Keys you have provided return true.
    Console.WriteLine(builder.ContainsKey("Integrated Security"))

    ' Keys that are valid but have not been set return true.
    Console.WriteLine(builder.ContainsKey("Unicode"))

    ' Keys that don't exist return false.
    Console.WriteLine(builder.ContainsKey("MyKey"))

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

Private Function GetConnectionString() As String
    ' To avoid storing the connection string in your code,
    ' you can retrieve it from a configuration file.
    Return "Server=OracleDemo;Integrated Security=True"
End Function

備註

因為 OracleConnectionStringBuilder 包含固定大小的索引鍵/值組集合,所以 ContainsKey 方法只會判斷特定的索引鍵名稱是否有效。

適用於

另請參閱