How to know if the type parameter is dynamic?

前端 未结 1 1932
你的背包
你的背包 2021-01-13 15:00

It seems that every time dynamic is used by the caller of a generic method, the type actually used is a simple object. For example, the code:

相关标签:
1条回答
  • 2021-01-13 15:43

    No, you cannot. Dynamic is all in the eye of the beholder (meaning: the compiler). It is implemented as dynamic. You can, however, check for IDynamicMetaObjectProvider: if an object implements that, the caller is probably talking about dynamic. Unfortunately, reflection also works inside dynamic, but will not involve IDynamicMetaObjectProvider at all.

    0 讨论(0)
提交回复
热议问题