In F# how can I produce an expression with a type of Func?

前端 未结 3 668
孤街浪徒
孤街浪徒 2021-02-12 22:38

I\'m working with an api that requires a value of type Func. (Specifically, I\'m trying to call ModelMetadataProviders.Current.GetMetadataForType().

How can I construct

3条回答
  •  情话喂你
    2021-02-12 23:00

    You can normally pass in any () -> obj and it will be automatically converted to Func. You may need to wrap your fun with Func:

    > let d : Func = Func(fun () -> box "hello");;
    
    val d : Func
    

提交回复
热议问题