Boxing is implicit, unboxing is explicit. Unboxing is the explicit conversion of a reference type created by boxing back to a value type.
Let us see an example of variables and objects in C# −
// int int x = 30; // Boxing object obj = x; // Un boxing int unboxInt = (int) obj;
The following is an example that shows Un boxing −
int x = 5; ArrayList arrList = new ArrayList(); // Boxing arrList.Add(x); // UnBoxing int y = (int) arrList [0];
The above is the detailed content of What is unboxing in C#?. For more information, please follow other related articles on the PHP Chinese website!