Monday, 9 October 2017

Explain the difference between boxing and unboxing. Provide an example.

Boxing is the process of converting a value type to the type object, and unboxing is extracting the value type from the object. While the boxing is implicit, unboxing is explicit.
Example (written in C#):
int i = 13;
object myObject = i;  // boxing 
i = (int)myObject; // unboxing 

No comments:

Post a Comment

React Hooks - custom Hook

  v CustomHook Ø React allows us to create our own hook which is known as custom hook. Example – 1 localStorage Demo Step-1 Create ...