C#'s 'dynamic' in F#

前端 未结 4 717
梦如初夏
梦如初夏 2020-12-31 02:26

One example of using the DLR in C# is as follows:

dynamic dyn = new MyObject();
dyn.MyMethod(); //resolved at runtime
         


        
4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-31 02:56

    F# has the ? operator which you use like so:

     myVariable?SomePropertyThatIsNotDeclared
    

    There is no dynamic keyword equivalent. Take a look at this article for how to use it https://weblogs.asp.net/podwysocki/using-and-abusing-the-f-dynamic-lookup-operator

提交回复
热议问题