Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

9. Other Framework Types > Boxing & Unboxing

Boxing & Unboxing

You know that C# will implicitly cast any type to one of its ancestors or an interface that it or one of its ancestors implements. Sometimes this means converting a value type to a reference type and vice versa, a process called BOXING and UNBOXING. It can happen whenever you cast a value type to an interface or to the base class of all .NET Framework types, System.Object.

image

On Your Own

image

Boxing happens transparently, but it’s something you need to be careful about. Why do you think that is? (Hint: re-read the discussion of value and reference types on page 274.)



  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint