Map.ContainsKey<'Key,'Value>-Methode (F#)

Prüft, ob sich ein Element in der Domäne der Zuordnung befindet.

Namespace/Modulpfad: Microsoft.FSharp.Collections

Assembly: FSharp.Core (in FSharp.Core.dll)

// Signature:
member this.ContainsKey : 'Key -> bool (requires comparison)

// Usage:
map.ContainsKey (key)

Parameter

  • key
    Typ: 'Key

    Der Eingabeschlüssel.

Rückgabewert

true, wenn die Zuordnung den angegebenen Schlüssel enthält.

Beispiel

Im folgenden Beispiel wird die Verwendung der ContainsKey-Methode veranschaulicht.

let map1 = Map.ofList [ (1, "one"); (2, "two"); (3, "three") ]
let findKeyAndPrint key (map : Map<int,string>) =
    if (map.ContainsKey key) then
        printfn "The specified map contains the key %d." key
    else
        printfn "The specified map does not contain the key %d." key
findKeyAndPrint 1 map1
findKeyAndPrint 0 map1

Output

      

Plattformen

Windows 7, Windows Vista SP2, Windows XP SP3, Windows XP x64 SP2, Windows Server 2008 R2, Windows Server 2008 SP2, Windows Server 2003 SP2

Versionsinformationen

F#-Runtime

Unterstützt in: 2.0, 4.0

Silverlight

Unterstützt in: 3

Siehe auch

Weitere Ressourcen

Collections.Map<'Key,'Value>-Klasse (F#)

Microsoft.FSharp.Collections-Namespace (F#)