Collection.Contains(String) 메서드

정의

Visual Basic Collection 개체에 특정 키를 가진 요소가 포함되어 있는지 여부를 나타내는 값을 반환합니다.

public:
 bool Contains(System::String ^ Key);
public bool Contains (string Key);
member this.Contains : string -> bool
Public Function Contains (Key As String) As Boolean

매개 변수

Key
String

필수 요소. 컬렉션 요소를 검색할 키를 지정하는 String 식입니다.

반환

Visual Basic Collection 개체에 특정 키가 있는 요소가 포함되어 있으면 true이고. 그러지 않으면 false입니다.

예제

Dim customers As New Microsoft.VisualBasic.Collection()
Dim accountNumber As String = "1234"
' Insert code that obtains new customer objects.
' Use the new customer's account number as the key.
customers.Add(newCustomer, accountNumber)
' The preceding statements can be repeated for several customers.
Dim searchNumber As String = "1234"
' Insert code to obtain an account number to search for.
If customers.Contains(searchNumber) Then
    MsgBox("The desired customer is in the collection.")
Else
    MsgBox("The desired customer is not in the collection.")
End If

컬렉션을 해당 키를 사용하여 요소를 검색하려는 경우 메서드를 호출할 때마다 인수를 KeyAdd 제공해야 합니다.

설명

Contains컬렉션에 정확히 일치하는 Key키가 있는 요소가 포함되어 있으면 를 반환 True 합니다. 그렇지 않으면 가 Contains 를 반환합니다 False. 키 값을 일치시키는 경우 대/소문자를 무시합니다.

Visual Basic Collection 은 키가 있는 일부 요소와 키가 없는 다른 요소를 보유할 수 있습니다. 이는 메서드 호출이 선택적 Key 매개 변수에 Add 인수를 제공하는지 여부에 따라 달라집니다.

적용 대상