Pages

Showing posts with label boxing. Show all posts
Showing posts with label boxing. Show all posts

Tuesday, September 27, 2011

Boxing and Unboxing in OOPS

Boxing is a process of conversion of a value to generic object type for example

Consider the following code

Int alpha=1;
object boxed_alpha= alpha;

This conversion to generic type is called as boxing

Unboxing is the reverse of a boxing continuing with the above example let us unbox boxed_alpha as a string

String string_alpha=(String) boxed_alpha;

OR

String string_alpha=boxed_alpha.ToString();

I will discuss its use subsequent comments