Unboxing
To return a boxed object back to a value type you must explicitely unbox the object.
You can unbox using DirectCast() or the CType() function
UnBoxing extracts the value type from the object Unboxing is explicit
object object2 = 54;
int value6 = (int)object2;
int myNumber2;
if (typeof(Object) Is int)
{
Number2 = DirectCast(Object, Integer);
}
If the Object being boxed is Null or is a reference to an object of a different type an InvalidCastException error occurs.
© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext