When to Use Value Types—When to Use Reference Types

You have already learned that value types were created primarily for better performance. For applications that need to process data extremely fast, it makes sense to use or create data types that can move easily within the computer’s memory. Some examples include:

  • An image requires a large amount of memory when it is loaded from the hard drive into main memory. The memory where an image is stored should of course be set up as a reference type. However, coordinates that define positions on the image and are incorporated into the algorithms for calculating the image should be stored as value types because they need to work quickly.

  • Datasets that you need to keep in memory (for example, for contact ...

Get Microsoft® Visual Basic® 2010 Developer’s Handbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.