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 > Reference & Value Types

Reference & Value Types

We’ve seen that when you instantiate an object, the .NET Framework will allocate memory to store it, and I’ve talked about how the garbage collection process collects the memory used by your classes. But we’ve been a bit vague about the whole thing, which is okay when you’re only working with classes, but things get just a little more complicated when you’re working with other types. Not much, but a little.

image

It all works fine and you don’t have to think about it very much with three exceptions:

image

Under the Microscope

image

Neither of the two .NET Framework value types, structures and enumerations, are allowed to specify a base class from which they inherit. There’s actually a little magic going on under the hood: The .NET Framework type System.ValueType, itself a reference type, contains the magic that causes its children to be stored directly on the stack. Don’t worry about it—it just works.


  

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