Search code examples
c#.netreflector

Is int32 a polymorphism of object?


When i do

int k=3;

where in the reflector can i find the pseudo statement?

Object k = new Int32();

where can i find the value assign?


Solution

  • Even though primitive types inherit from Object, the .net Framework treats them in a special way. An int is an int and treated using functions like ldc.i4 (loads a 32-bit constant onto the stack).

    In situations where an object is needed, an int is indeed cast to Object through a process called boxing.