F# collection initializer syntax

后端 未结 6 628
猫巷女王i
猫巷女王i 2021-02-03 19:05

What is the collection initializer syntax in F#? In C# you can write something like:

new Dictionary() {
    {\"One\", 1},
    {\"two\", 2}}
         


        
6条回答
  •  自闭症患者
    2021-02-03 19:33

    You can use the same :

    open System.Collections.Generic
    
    Dictionary(dict [ (1, "a"); (2, "b"); (3, "c") ])
    

    Cheers.

提交回复
热议问题