h1.post-title { color:orange; font-family:verdana,Arial; font-weight:bold; padding-bottom:5px; text-shadow:#64665b 0px 1px 1px; font-size:32px; } -->

Pages

Boxing and unboxing with Example

Boxing:
Boxing is the Process of Converting a Value Type to the type Object.
Store a value type in the Garbage-Collection.

Unboxing:
              Unboxing is a explicit conversion from the type object to a Value Type.
Checking the object instance to make sure that it is a boxed value of the given value type.
Copying the value from the instance into the value-type variable.
 
Boxing Example:
Int i = 123; // a value type
Object o = i;
UnBoxing Example:
Int i = 123; // a value type
Object o = i;
Int j = (int) o; // UnBoxing
use of converting values:
based on your requirement.
For Example: I want to display a value in MessageBox.If my My value data type is Integer.So I want to convert that value into string .
Ex:
int i=10;
MessageBox.show(i.Tostring());
So I get a integer value into string

No comments:

Post a Comment