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

前端 未结 5 1694
北荒
北荒 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:06

    In C# dynamic means no complile-time check and it's gonna have the type of the other side of the = symbol. However GetType is a runtime evaluation, so you always gonna retrieve declared type and not dynamic.

    You can read a little bit more here: http://msdn.microsoft.com/en-us/magazine/gg598922.aspx

提交回复
热议问题