Is there anyway to use C# implicit operators from F#?

前端 未结 3 644
傲寒
傲寒 2021-01-07 23:35

If I have a C# class with implicit conversion to double, like so:

public class Parameter
{
    private double _value;
         


        
3条回答
  •  既然无缘
    2021-01-07 23:47

    FSharp.Interop.Dynamic uses the DLR, so for most people probably overkill, but has a function Dyn.implicitConvert for dynamically using the C# implicit operator.

       [] member basic.``Test Implicit Conversion`` ()=
                        let ele = 50
                        ele |> Dyn.implicitConvert |> should equal (decimal 50)
    

提交回复
热议问题