4.9. Value Types vs. Reference Types
Types in C# are divided into two categories—value types and reference types.
C#’s simple types (like
double) are all value types. A variable of a value type simply contains a value of that type. For example, Fig. 4.10 shows an
int variable named
count that contains the value
Fig. 4.10. Value-type variable.
By contrast, a reference-type variable (sometimes called a reference) contains the address of a location in memory where the data referred to by that variable is stored. Such a variable is said to refer to an object in the program. Line 11 of Fig. 4.8 creates a ...
Get Visual C#® 2012: How to Program, Fifth Edition now with O’Reilly online learning.
O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.