Collection.Contains(String) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
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 합니다. 그렇지 않으면 . ContainsFalse 키 값을 일치시키는 경우 대/소문자를 무시합니다.
Visual Basic Collection 키와 키가 없는 다른 요소가 있는 일부 요소를 보유할 수 있습니다. 이는 메서드 호출이 선택적 Key 매개 변수에 Add 인수를 제공하는지 여부에 따라 달라집니다.