다음을 통해 공유


ExtraTopLevelOperators.dict<'Key,'Value> 함수(F#)

업데이트: 2010년 5월

키/값 쌍의 시퀀스에서 읽기 전용 조회 테이블을 빌드합니다. 키 개체는 제네릭 해시 및 같음을 사용하여 인덱싱됩니다.

네임스페이스/모듈 경로: Microsoft.FSharp.Core.ExtraTopLevelOperators

어셈블리: FSharp.Core(FSharp.Core.dll)

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

// Usage:
dict keyValuePairs

매개 변수

  • keyValuePairs
    형식: seq<'Key * 'Value>

반환 값

지정된 컬렉션을 나타내는 IDictionary<TKey, TValue>를 구현하는 개체입니다.

설명

컴파일된 어셈블리에서 이 함수의 이름은 CreateDictionary입니다. F# 이외의 언어에서 함수에 액세스하거나 리플렉션을 통해 함수에 액세스하는 경우 이 이름을 사용합니다.

예제

다음 코드 예제에서는 dict 함수를 사용하는 방법을 보여 줍니다.

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) 

출력은 다음과 같습니다.

      

플랫폼

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

참고 항목

참조

Core.ExtraTopLevelOperators 모듈(F#)

Microsoft.FSharp.Core 네임스페이스(F#)

변경 기록

날짜

변경 내용

이유

2010년 5월

코드 예제를 추가했습니다.

향상된 기능 관련 정보