Search This Blog

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);
         

    }

}


                            

Post a Comment

If you have any doubt in programming or join online classes then you can contact us by comment .

Previous Post Next Post