Demonstrating boxing and unboxing - c# program, DOT NET Programming

Demonstrating Boxing and Unboxing - C# Program

Hi,

Can any of you, tell me how to use boxing and Unboxing in c#?

Posted Date: 2/11/2013 5:44:31 AM | Location : United States





You might check out this, this is useful for you

Demonstrating Boxing and Unboxing - C# Program

using System; 

class Boxing 

      public static void main(string[] a) 

       { 

            //  BOXING 

               int m = 10; 

               object om = m; // creates a box to hold m 

               m = 20; 

              Console.WriteLine("****** BOXING *****"); 

              Console.WriteLine("m = " + m); // m = 20 

              Console.WriteLine("om = " +om);// om = 10 

              Console.ReadLine(); 

            //  UNBOXING 

               int n = 10; 

               object on = n; // box n (creates a box to hold n) 

               int x = (int)on; // unbox on back to an int 

              Console.WriteLine("**** UNBOXING *****"); 

              Console.WriteLine("n = " + n); // n = 20 

              Console.WriteLine("on = " +on);// on = 10 

              Console.ReadLine(); 

          } 

}

Posted by Max | Posted Date: 2/11/2013 5:48:02 AM

Hey Max you are a GREAT instructor! As a C# beginner, this is the first time out of at least three previous tried?that I can finally understand what is boxing and unboxing in c#.

Posted by Bella | Posted Date: 2/11/2013 5:50:52 AM


Related Discussions:- Demonstrating boxing and unboxing - c# program, Assignment Help, Ask Question on Demonstrating boxing and unboxing - c# program, Get Answer, Expert's Help, Demonstrating boxing and unboxing - c# program Discussions

Write discussion on Demonstrating boxing and unboxing - c# program
Your posts are moderated
Related Questions
What is UDDI? The Full form of the UDDI is Universal Description, Discovery and Integration. The directory that can be used to publish and discover public Web Services. If you

Question: (a) Outline four classes that allow you to work with File Streams. (b) (i) What potential problem can arise when you change items stored in an Application State

Web Based Inventory Management System Project Description: I need a build in software which has the subsequent features, if anybody has ready to use web based application, pl

What is .NET Remoting? The .NET remoting is replacement of DCOM. Using .NET remoting you can make remote object calls that lie on different Application Domains. since the remot

C# coding to include user specified screen recording to app Project Description: Reposting as selected coder didn't read brief and accepted job to do then tell me would be in

What is Extensible Markup Language (XML). XML is an easy and flexible mark-up language in the text format. Nowadays, it is widely used to exchange a large variety of data over

Unity 4 iOS Pro Developer to prepare link.xml Project Description: I'm seeking an iOS developer with a Unity 4 iOS Pro license to prepare a link.xml file that will let my pro

Describe the services that UDDI provides to Web applications. UDDI gives the following types of services to a Web application: XML Schema for business descriptions - Contain

Project Description: I want very simple app in C# in visual studio Windows forms app Very simple database management app - three buttons - search , delete, add records and

What is Manual Reset Event and Auto Reset Event? The Threads that call one of the wait methods of a synchronization event should wait until other thread signals the event by ca