Probably I may be confused with boxing and unboxing.
Consider the following statement from MSDN:
"Unboxing is an explicit conversion from the type object to a value type or from an interface type to a value type that implements the interface."
So, this implies that unboxing can only be applied to a value type parameter.
so, this is OK.
var concernedInteger = (int)myObject; //unboxing is ok.
Since class is a reference type, this should not work (because unboxing is only applicable to value type)
var concernedClassObject = (TestClass)testClassObject // unboxing is still ok.
My ReSharper does not show any error.
So, my question is "How can you unbox a reference type variable when MSDN says that only value types can be unboxed" ?
This isn't unboxing. It is
type casting
.Unboxing is pulling the value from a reference out into a value type (assuming the cast will succeed). When you're moving reference types around like that.. it's just normal type casting.
Boxing and Unboxing are both types of
type casting
anyway. The reason they are given special names (boxing and unboxing) is because more goes on in a managed environment rather than just a couple of lookup tables being altered. This is why they are separated into the terms boxing and unboxing for value types.. but when it comes to reference types.. it's just type casting.