ExtraTopLevelOperators.dict<'Key,'Value> İşlevi (F#)

Bir anahtar/değer çiftinin dizisinden salt okunur arama tablosu oluşturur.Anahtar nesneler genel karma ve eşitlik kullanılarak dizinlenir.

Ad alanı/modül yol: Microsoft.FSharp.Core.ExtraTopLevelOperators

Derleme: FSharp.Core (FSharp.Core.dll),

// Signature:
dict : seq<'Key * 'Value> -> IDictionary<'Key,'Value> (requires equality)

// Usage:
dict keyValuePairs

Parametreler

  • keyValuePairs
    Türü: seq<'Key * 'Value>

Dönüş Değeri

Uygulayan bir nesne IDictionary verilen koleksiyonunu temsil eden.

Notlar

Bu işlev adlı CreateDictionary kodları derlenmiş derlemeleri.İşlev yansıtma veya F# dışındaki bir dilde erişiyorsanız, bu adı kullanın.

Örnek

Aşağıdaki kod örneği kullanımını göstermektedir dict işlevi.

open System
open System.Collections.Generic

let seq1 = seq { for i in 1..10 -> i, i*i }
let dictionary1 = dict seq1
if dictionary1.IsReadOnly then
    Console.WriteLine("The dictionary is read only.")
// The type is a read only IDictionary. 
// If you try to add or remove elements, 
// NotSupportedException is generated, as in the following line: 
//dictionary1.Add(new KeyValuePair<int, int>(0, 0)) 
// You can use read-only methods as in the following lines. 
if dictionary1.ContainsKey(5) then
    Console.WriteLine("Value for key 5: {0}", dictionary1.Item(5))
for elem in dictionary1 do
   Console.WriteLine("Key: {0} Value: {1}", elem.Key, elem.Value) 

Çıktı aşağıdaki gibidir.

  
  

Platformlar

Windows 8, Windows 7, Windows Server 2012, Windows Server 2008 R2

Sürüm Bilgisi

F# Çekirdek Kitaplığı sürümleri

Desteklenen: 2.0, 4.0, Portable

Ayrıca bkz.

Başvuru

Core.ExtraTopLevelOperators Modülü (F#)

Microsoft.FSharp.Core Ad Alanı (F#)