RSS

Boxing vs. UnBoxing in C# .NET

26 Dec

You might be read about these expressions (I mean Boxing & UnBoxing) for the first time … but I’ll explain them in shortly as following :

Boxing

Boxing is process of converting ValueType variable to ReferenceType variable at runtime.

Follow this example:

int x = 7;
string strNew = Convert.ToString(x);

UnBoxing

Unboxing is a process of converting ReferenceType variable  to ValueType variable at run time.

Follow this example:

string strNew = “7”;
int x = Convert.ToInt16(strNew) ;

 
Leave a comment

Posted by on December 26, 2011 in Visual C# . NET

 

Tags: , , , , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: