DbConnectionStringBuilder.Item[String] 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
지정된 키와 연결된 값을 가져오거나 설정합니다.
public:
virtual property System::Object ^ default[System::String ^] { System::Object ^ get(System::String ^ keyword); void set(System::String ^ keyword, System::Object ^ value); };
public virtual object this[string keyword] { get; set; }
[System.ComponentModel.Browsable(false)]
public virtual object this[string keyword] { get; set; }
member this.Item(string) : obj with get, set
[<System.ComponentModel.Browsable(false)>]
member this.Item(string) : obj with get, set
Default Public Overridable Property Item(keyword As String) As Object
매개 변수
- keyword
- String
가져오기 또는 설정할 항목의 키입니다.
속성 값
지정된 키와 연결된 값입니다. 지정된 키를 찾을 수 없으면 키를 가져와 ArgumentException서 설정하려고 하면 지정된 키를 사용하여 새 요소가 만들어집니다.
null(Visual Basic Nothing) 키를 전달하면 ArgumentNullException throw됩니다. null 값을 할당하면 키/값 쌍이 제거됩니다.
- 특성
예외
컬렉션에 대한 keyword 값이 설정되지 않았습니다.
keyword null 참조입니다(Visual Basic Nothing).
속성이 설정되고 DbConnectionStringBuilder 읽기 전용입니다.
-또는-
속성이 설정되고 컬렉션 keyword 에 존재하지 않으며 크기가 DbConnectionStringBuilder 고정되어 있습니다.
예제
다음 콘솔 애플리케이션은 새 DbConnectionStringBuilder 만들고 Item[] 속성을 사용하여 연결 문자열 키/값 쌍을 추가합니다.
static void Main()
{
DbConnectionStringBuilder builder = new
DbConnectionStringBuilder();
builder["Data Source"] = "(local)";
// Note that Item is the indexer, so
// you do not include it in the reference.
builder["integrated security"] = true;
builder["Initial Catalog"] = "AdventureWorks";
// Overwrite the existing value for the Data Source key,
// because it already exists within the collection.
builder["Data Source"] = ".";
Console.WriteLine(builder.ConnectionString);
Console.WriteLine();
Console.WriteLine("Press Enter to continue.");
Console.ReadLine();
}
Module Module1
Sub Main()
Dim builder As New DbConnectionStringBuilder
builder.Item("Data Source") = "(local)"
' Item is the default property, so
' you need not include it in the reference.
builder("integrated security") = True
builder.Item("Initial Catalog") = "AdventureWorks"
' Overwrite the existing value for the data source value,
' because it already exists within the collection.
builder.Item("Data Source") = "."
Console.WriteLine(builder.ConnectionString)
Console.WriteLine()
Console.WriteLine("Press Enter to continue.")
Console.ReadLine()
End Sub
설명
이 속성을 설정하면 지정된 키가 사전에 이미 있으면 값이 바뀝니다. 그렇지 않으면 새 요소가 만들어집니다.