Is there a way to test if a variable is dynamic?

前端 未结 5 1683
北荒
北荒 2020-12-18 18:26

The following piece of code will always return true unless the variable v is null:

v is dynamic

and the following

5条回答
  •  遥遥无期
    2020-12-18 19:25

    There is no CLR type called dynamic. The C# compiler makes all dynamic values of type object and then calls custom binding code to figure out how to handle them. If dynamic was used, it will show up as Object.

    But You can check if an instance is of type IDynamicMetaObjectProvider or you can check whether the type implements IDynamicMetaObjectProvider

提交回复
热议问题