1
Vote

Chapter 13 boxing

description

In the last Pool Puzzle Solution in chapter 13 (page 648, 3rd edition), the Lamp() function in structure Table requires an argument which is object. The bonus question is finding where boxing happens.
I'm confused by by the hint nearby. It says "Since the Lamp() method takes an object parameter, boxing automatically happens when it’s passed an int or a string."
We know that string in C# is the alias of System.String, which is an abstract class. Thus string is exactly reference type, not value type like int. So why it says "int or string" will cause boxing happens? Or does it need boxing to convert a string to an object?

comments