I wonder if boxing is taking place in order for ToString() to be called on the integer literal (5):
5.ToString();
Oh, and if not, what is taking place in order for the CLR to be able to call the ToString() method?
I wonder if boxing is taking place in order for ToString() to be called on the integer literal (5):
5.ToString();
Oh, and if not, what is taking place in order for the CLR to be able to call the ToString() method?
Copyright © 2021 Jogjafile Inc.
No, that doesn't require boxing - because
int
overridesToString
. The compiler can determine exactly which method will be called, so it doesn't need to go through virtual dispatch. It doesn't even use callvirt - that call will correspond to IL ofIf you don't override
ToString()
(etc) in a struct, then calls to the virtual method will require boxing.