O'Reilly logo

Visual C#® 2012: How to Program, Fifth Edition by Harvey Deitel, Paul Deitel

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

4.9. Value Types vs. Reference Types

Types in C# are divided into two categories—value types and reference types.

Value Types

C#’s simple types (like int and 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 7.

Image

Fig. 4.10. Value-type variable.

Reference Types

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 ...

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