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 the namespace in which .NET have the data functionality classes? System.data : This namespace contains the basic objects used for accessing &  storing relational d

What are Daemon threads? Daemon thread's run in the background and stop automatically when nothing is running program. The Example of a Daemon thread is the "Garbage collector"

Project Description: This project uses Microsoft Visual Studio 2010/2012, Internet Information Services (IIS) Manager and Microsoft SQL Server Management Studio. It is a Mobi

Explain different types of XML Application Programming Interface (API). The following are two main parts of XML parsers: Tree-based API - Compiles an XML document into a tre

What are the problems that can occur if you do not implement locking properly in SQL SERVER? The problems that occur if you do not implement locking properly in SQL SERVER is a

I need C# Programmer Project Description: To help in the production of a C# module to provide a web service. We are based in Littlehampton, West Sussex. Skills required ar


TFS - SpiraTeam synchronization plugin. Project Description: We would like you to develop the subsequent requirements in one plug-in already in production. The plug-in was de

Full time contractual programming position (mostly scraping, databasing) Project Description: This is a full time contractual role needed for a sports advisory service. We ar

What are the advantages of Distributed Processing? Benefits of distributed programming are:- a. Security/Encapsulation b. Faster Problem solving c. Distributed databas