For a simple example:
int a = 1;
a.ToString();
Since
a
is a value type andToString
method operates on object, may I ask if there is a boxing ona
?More generally, I learnt that value types and reference/object types are two different concepts. Nevertheless, I noticed that there is the ValueType class in C# inheriting from
System.Object
in which all value types are inheriting from. I am a bit confused at this point: are value types themselves being treated as instances of the ValueType class, or are they being boxed into instances of the ValueType class?And thus, when does the computer treats value types as an object of a class, and when does not?