Results 1 to 6 of 6

Thread: Advantages of boxing

  1. #1
    Join Date
    Dec 2009
    Posts
    32

    Advantages of boxing

    Hello friends,

    The Object oriented programming comprises quit complicated concept. And one of them is "Boxing". I think the "Boxing" concept is entirely different from the tape casting. I don't have enough knowledge about the boxing. If you know then please let know someadvantages of boxing concept from the object oriented programming. It will be great you gives any suitable example for this concept.

  2. #2
    Join Date
    May 2008
    Posts
    2,389

    Re: Advantages of boxing

    Boxing concept of the OOPs is useful to create a reference type, on the heap, that contains the boxed value and a type code. So, there's the modest cost of allocation and the modest cost of copying data. Boxing is converting a value-type to reference type. An example is converting an integer value to an object value. If the boxing operation is being performed on a value type that is declared within your code, remove the structure, and use an object type instead.

  3. #3
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Advantages of boxing

    Boxing a of the value type is used to allocates an object instance on the heap and copies the value into the new object. if you are using a value type (struct) declared outside of your code (such as an integer, string, boolean, etc.) you generally cannot eliminate the boxing operation. Boxing is used to store value types in the garbage-collected heap. Boxing is an implicit conversion of a value type to the type object or to any interface type implemented by this value type.

  4. #4
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Advantages of boxing

    The advantage of boxing is that you can pass, say, an integer around as an object. Secondarily, you can have data structures that can hold any type of value, like an object[] or 1.x's ArrayList and HashTable.Boxing a value type allocates an object instance on the heap and copies the value into the new object. The advantage of unboxing is you get you native integer performance back.It also possible to perform the boxing explicitly as in the following example, but explicit boxing is never required.

  5. #5
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Advantages of boxing

    The boxing operation creates a copy of the value of the integer to the object. Objects based on nullable types are only boxed if the object is non-null. Now both the variables m and o exist but the value of o resides on the heap. This means that the values are independent of each other.The Microsoft standards says that to avoid Unnessary casting boxing because when we cast an object to Object class the Memory space allocated by the system is more and the performance may go down .

  6. #6
    Join Date
    May 2008
    Posts
    2,012

    Re: Advantages of boxing

    In boxing when a Variables Once Boxed are stored on Heap Memory and thus independent to each other. So if your application needs such a independent variable, use Boxing. The two boxed objects are identical to those created by boxing non-nullable types. The behavior of nullable types when boxed provides: boxed nullable types fully support the functionality of the underlying type, as well as Nullable objects and their boxed counterpart can be tested for null.

Similar Threads

  1. Help!! Java 5, boxing and auto switch.
    By Dewei in forum Software Development
    Replies: 5
    Last Post: 22-09-2010, 10:15 PM
  2. BOXING and UNBOXING in CSharp
    By Izek in forum Software Development
    Replies: 3
    Last Post: 21-11-2009, 11:57 PM
  3. What are the advantages of PHP
    By SMG in forum Software Development
    Replies: 3
    Last Post: 14-09-2009, 08:57 PM
  4. Don King Boxing (Wii)
    By Edmund in forum Reviews
    Replies: 2
    Last Post: 14-04-2009, 12:18 AM
  5. Don King Boxing (Nintendo Wii)
    By Reegan in forum Video Games
    Replies: 1
    Last Post: 30-12-2008, 07:42 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,750,657,978.73661 seconds with 16 queries