Duck type testing with C# 4 for dynamic objects

前端 未结 5 468
遇见更好的自我
遇见更好的自我 2020-12-02 22:57

I\'m wanting to have a simple duck typing example in C# using dynamic objects. It would seem to me, that a dynamic object should have HasValue/HasProperty/HasMethod methods

5条回答
  •  执笔经年
    2020-12-02 23:44

    http://code.google.com/p/impromptu-interface/ Seems to be a nice Interface mapper for dynamic objects... It's a bit more work than I was hoping for, but seems to be the cleanest implementation of the examples presented... Keeping Simon's answer as correct, since it is still the closest to what I wanted, but the Impromptu interface methods are really nice.

提交回复
热议问题