Wednesday, August 9, 2023

 

Code2Know


Boxing and Unboxing

Conversion of the value type to the reference type is known as boxing - implicit

V > O 
int v = 1; object o = v;

Converting the reference type back to the value type is known as unboxing - explicit

O > V
object o = 5; int v = (int) o;

CLR boxes a value type, it wraps the value inside a System.Object instance and stores it on the managed heap. 


Array & ArrayList

Both support the same type, Array is for fixed size and ArrayList is dynamic


ref & out

Both support the same type, Array is for fixed size and ArrayList is dynamic

No comments:

Post a Comment