Thursday, December 25, 2014

Boxing and Unboxing

6:08 AM - By azeheruddin khan 0

Boxing is the process of converting a value of a value type into a value of corresponding reference type. It is an implicit conversion.

Unboxing is the process of converting a value of an object type to any value type. It is an explicit conversion. An unboxing operation first consists of checking whether an object instance is a boxed value of a given value type and then that object type is converted to a value type. 

using System;
namespace DataType
    class Program
        static void Main(string[] args)
            int i = 1;
            object o = i; //Boxing
            object b = 12;
            int c = (int)b; //Unboxing



About the Author

I am Azeheruddin Khan having more than 6 year experience in c#, and ms sql.My work comprise of medium and enterprise level projects using and other Microsoft .net technologies. Please feel free to contact me for any queries via posting comments on my blog,i will try to reply as early as possible. Follow me @fresher2programmer
View all posts by admin →

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post



© 2014 Fresher2Programmer. WP Theme-junkie converted by Bloggertheme9
Powered by Blogger.
back to top