Lecture overview -- Keyboard shortcut: 'u'  Previous page: Constructors in C# -- Keyboard shortcut: 'p'  Next page: Initialization of class variables -- 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 28 : 29
Object-oriented Programming in C#
Classes and Objects
Copy constructors

The easy way to program object copying is via copy constructors. A copy constructor takes a single parameter of the same type as the surrounding class.

It is sometimes useful to have a constructor that creates an identical copy of an existing object

/user/normark/oop-csharp-1/sources/c-sharp/Die-variants/die-copy-constructor/die.csThe class Die with a copy constructor.


The use of copy constructors is particularly useful when we deal with mutable objects

Read more about Copy constructors in the text book version of this material.