What is boxing and unboxing concept in c#

0
what are the boxing and unboxing concept in c#:-

Boxing means to convert primitive type data to object type for example if we convert int, char, float to Object then it is called boxing.it is also called implicit conversion in c# because it will automatically convert the value.


Unboxing means to convert Object type data to Value type for example if we convert  Object to int, char, float then it is called Unboxing.it is also called explicit conversion in c# because it will manually convert the value.


using System;

class Boxing
{
    public static void Main()
    {
          object o;
          int b=100,c;
          o=b;   //boxing
          Console.WriteLine(o);
          c=(int)o; //Unboxing
          Console.WriteLine(c);
         

    }

}


                            
Tags

Post a Comment

0Comments

POST Answer of Questions and ASK to Doubt

Post a Comment (0)