O'Reilly logo

Applied Microsoft® .NET Framework Programming by Jeffrey Richter

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Reference Types and Value Types

The CLR supports two kinds of types: reference types and value types. Of the two, you’ll run into reference types much more often. Reference types are always allocated from the managed heap, and the C# new operator returns the memory address of the object—the memory address refers to the object’s bits. You need to bear in mind some performance considerations when you’re working with reference types. First consider these facts:

  • The memory must be allocated from the managed heap.

  • Each object allocated on the heap has some additional overhead members associated with it that must be initialized.

  • Allocating an object from the managed heap could force a garbage collection to occur.

If every type were a reference type, an ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required