你如何从F#调用接受Action<T>参数的C#函数?

huangapple go评论89阅读模式
英文:

How can I call a C# function that takes an Action<T> from F#?

问题

我需要从F#调用这个函数,并传递一个BinanceRestOptions对象?

英文:

I need to call this function, from a C# lib:

  1. public BinanceRestClient(Action&lt;BinanceRestOptions&gt; optionsDelegate)
  2. : this((HttpClient) null, (ILoggerFactory) null, optionsDelegate)
  3. {
  4. }

How can I call it from F# and pass a BinanceRestOptions object?

答案1

得分: 2

将匿名函数传递给它,例如:

  1. let bc = BinanceRestClient(fun opts -> ())

或者

  1. let bc = BinanceRestClient(fun opts ->
  2. opts.SomeProp <- 1
  3. opts.SomeOtherProp <- "" )
英文:

Pass an anonymous function to it, for example:

  1. let bc = BinanceRestClient(fun opts -&gt; ())

or

  1. let bc = BinanceRestClient(fun opts -&gt;
  2. opts.SomeProp &lt;- 1
  3. opts.SomeOtherProp &lt;- &quot;&quot; )

huangapple
  • 本文由 发表于 2023年7月13日 19:15:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/76678747.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定