Boxing and UnBoxing in C# Console Application - C# Tutorials

Latest

For Video tutorials Visit my Channel https://www.youtube.com/channel/UCVWpZVbMqLHuQBigIfc9I8Q

Friday, 13 January 2017

Boxing and UnBoxing in C# Console Application

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BoxingUnboxing
{
    class Program
    {
        static void Main(string[] args)
        {
            /*Boxing : In Boxing a value type data type is converted to a reference type or object type.*/

             int a=10;
             object b=a;
             Console.WriteLine(b);

            /*Unboxing : In Unboxing a reference type data type is converted into a value type.*/

             int c = 10;
             object d=c;
             int e=(int)d;
             Console.WriteLine(e);
             Console.ReadKey();
        }
    }

}

No comments:

Post a Comment