Below is a example or sample sourecode demonstrating Boxing and UnBoxing in C#
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { internal class Program { // Abundantcode - Demonstrate Boxing and UnBoxing in C# private static void Main(string[] args) { double ValueType; object ReferenceType; ValueType = 500; //Boxing - Value type to Object ReferenceType = ValueType; // UnBoxing - Reference Type to Value double Result = (double)ReferenceType; Console.WriteLine(Result); Console.ReadLine(); } } }
Leave a Reply