共用方式為


Lookup<TKey, TElement>.Contains Method

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Determines whether a specified key is in the Lookup<TKey, TElement>.

Namespace:  System.Linq
Assembly:  System.Core (in System.Core.dll)

Syntax

'Declaration
Public Function Contains ( _
    key As TKey _
) As Boolean
public bool Contains(
    TKey key
)

Parameters

Return Value

Type: System.Boolean
true if key is in the Lookup<TKey, TElement>; otherwise, false.

Implements

ILookup<TKey, TElement>.Contains(TKey)

Examples

The following example demonstrates how to use Contains to determine whether a Lookup<TKey, TElement> contains a specified key. This code example is part of a larger example provided for the Lookup<TKey, TElement> class.

' Determine if there is a key with the value 'G' in the Lookup.
Dim hasG As Boolean = lookup.Contains("G"c)
// Determine if there is a key with the value 'G' in the Lookup.
bool hasG = lookup.Contains('G');

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.