.net - When calling an object method on an integer literal (such as ToString), is the CLR boxing the literal first? -
i wonder if boxing taking place in order tostring() called on integer literal (5):
5.tostring();
oh, , if not, taking place in order clr able call tostring() method?
no, doesn't require boxing - because int
overrides tostring
. compiler can determine method called, doesn't need go through virtual dispatch. doesn't use callvirt - call correspond il of
call instance string [mscorlib]system.int32::tostring()
if don't override tostring()
(etc) in struct, calls virtual method require boxing.
Comments
Post a Comment