Why we need boxing in C#. Explain.

Solution

Boxing is used to convert value type (primitive data type) into Reference type.

For example, suppose you want to use ArrayList of type double of int i.e. ArrayList<int> or ArrayList<double> then we need to convert Int or double to object type as ArrayList does not support object types.

Usage

Boxing is used to pass the value type parameters as reference type parameters.

Share this thread

Comments

Comments
comments powered by Disqus

Navigation

Social Media