c# - Does casting a generic type using the dynamic keyword cause boxing? -


will following code cause boxing of integer passed call genericmethod?

void genericmethod<t>(t value) {   int test = (dynamic)value; }  void main() {   genericmethod(100); } 

according c# specification §4.7 dynamic type:

dynamic considered identical object except in following respects:

  • operations on expressions of type dynamic can dynamically bound (§7.2.2).

  • type inference (§7.5.2) prefer dynamic on object if both candidates.

so, casting dynamic cause boxing in same way casting object.


Comments