次の方法で共有


Map.ContainsKey<'Key,'Value> メソッド (F#)

要素がマップのドメイン内に存在するかどうかをテストします。

名前空間/モジュール パス: Microsoft.FSharp.Collections

アセンブリ: FSharp.Core (FSharp.Core.dll 内)

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

// Usage:
map.ContainsKey (key)

パラメーター

  • key
    型: 'Key

    入力キー。

戻り値

指定されたキーがマップに含まれている場合は true。

使用例

ContainsKey メソッドの使用方法を次のコード例に示します。

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

出力

      

プラットフォーム

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

バージョン情報

F# ランタイム

サポート対象: 2.0、4.0

Silverlight

サポート: 3

参照

その他の技術情報

Collections.Map<'Key,'Value> クラス (F#)

Microsoft.FSharp.Collections 名前空間 (F#)