{"id":134,"date":"2014-08-08T12:28:24","date_gmt":"2014-08-08T12:28:24","guid":{"rendered":"http:\/\/mairwa.com\/wordpress\/?p=134"},"modified":"2014-08-08T12:28:24","modified_gmt":"2014-08-08T12:28:24","slug":"boxing-and-unboxing","status":"publish","type":"post","link":"http:\/\/mairwa.com\/wordpress\/?p=134","title":{"rendered":"Boxing and Unboxing"},"content":{"rendered":"<p>Boxing is used to store value types in the garbage-collected heap. Boxing is an implicit conversion of a <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/s1ax56ch.aspx\">value type<\/a> to the type object or to any interface type implemented by this value type. Boxing a value type allocates an object instance on the heap and copies the value into the new object<\/p>\n<div>Boxing Conversion<\/div>\n<p><img decoding=\"async\" id=\"vcBoxingConversion\" title=\"BoxingConversion graphic\" alt=\"BoxingConversion graphic\" src=\"http:\/\/i.msdn.microsoft.com\/dynimg\/IC97798.gif\" \/><\/p>\n<p>explicit boxing is never required:<\/p>\n<p>Unboxing is an explicit conversion from the type object to a <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/s1ax56ch.aspx\">value type<\/a> or from an interface type to a value type that implements the interface. An unboxing operation consists of:<\/p>\n<p>&#8212;Checking the object instance to make sure that it is a boxed value of the given value type.<\/p>\n<p>&#8212;Copying the value from the instance into the value-type variable.<\/p>\n<div>Unboxing Conversion<\/div>\n<p><img decoding=\"async\" id=\"vcUnBoxingConversion\" title=\"UnBoxing Conversion graphic\" alt=\"UnBoxing Conversion graphic\" src=\"http:\/\/i.msdn.microsoft.com\/dynimg\/IC135292.gif\" \/><\/p>\n<p>unboxing of value types to succeed at run time<\/p>\n<p>int i = 123;\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ a value type<br \/>\nobject o = i;\u00a0\u00a0\u00a0\u00a0 \/\/ boxing<br \/>\nint j = (int)o;\u00a0\u00a0 \/\/ unboxing<\/p>\n","protected":false},"excerpt":{"rendered":"<p class=\"excerpt\">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. Boxing a value type allocates an object instance on the heap and copies the value into the new object Boxing Conversion explicit boxing is never required:&hellip; <a href=\"http:\/\/mairwa.com\/wordpress\/?p=134\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-134","post","type-post","status-publish","format-standard","hentry","category-c-vb","xfolkentry"],"_links":{"self":[{"href":"http:\/\/mairwa.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/134","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/mairwa.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/mairwa.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/mairwa.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/mairwa.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=134"}],"version-history":[{"count":0,"href":"http:\/\/mairwa.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/134\/revisions"}],"wp:attachment":[{"href":"http:\/\/mairwa.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=134"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/mairwa.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=134"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/mairwa.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=134"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}