Lecture overview -- Keyboard shortcut: 'u'  Previous page: Reference Types -- Keyboard shortcut: 'p'  Next page: Overview of reference types in C# -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home  Page 3 : 29
Object-oriented Programming in C#
Reference types, Value types, and Patterns
Illustration of variables of reference types

On this page we explain what happens in the assignment p1 = p2, where both p1 and p2 are variables of compatible reference types. See the similar example for value types on a later page.

Variables of reference types. The situation before the assignment p1 = p2.

Point p1 = new Point(1.0, 2.0),
      p2 = new Point(3.0, 4.0);

p1 = p2;

The variables p1 and p2 refer to two points. p1 is assigned to p2.

Variables of reference types. The situation after the assignment p1 = p2.