Whenever I Search for Boxing in c#, I come across a cliche example like following:
string s = "something";
Object o = s;
This is very simple to understand that a value type is cast into a very generic reference type at run time. Well and good. I want to talk about little more specific kind of boxing:
int i= something;
String s2 = 2
- Hoping that this example qualifies for the definition of boxing, I would like to note that it is not limited to string to String. It also applies to int to Integer.
- If I am not wrong all primitive type are primitive representation of their corresponding reference type and they are something we can call "light weight wrappers"
- Now my question is that is there ANY benefit of boxing primitive type to its corresponding reference type at run time at all?