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
Give a small explanation of all Elements in the diagram. Action State: - This is a type of state that has an internal action and one outgoing event that would do the int

What is a delegate? The Delegate is the class that can hold a reference to a method or a function. The Delegate class has a signature and it can only reference to those methods

How do we configure "WebGarden"? The process model configured the "Web garden" settings in the "machine.config" or in the "Web.config" file. The configuration section is named

What advantages have Web services over Component Object Model (COM) and Distributed Component Object Model (DCOM)? The benefits of Web services over COM and DCOM are as follow

What is a Cloud Service? A cloud service is used to build cloud applications. This service gives the facility of using the cloud application without installing it on the comput

What is the difference between thread and process? The thread is a path of execution which can run on CPU; a process is a collection of threads that share the same virtual memo

What is the difference between "Web farms" and "Web garden"? The "Web farms" are used to have some redundancy to reduce the failures. It consists of two or more web server of t

How to Learn Dot Net Online and get online certificate ?

I want a C# school project Project Description: The project is made in C# and haves a database connection. We have some small problems asking up data from the database.

Write a C# program (C# console application) that plays a word game with the user. The program should ask the user to enter the following: • His or her name • His or her age