What do you think will be printed by this code?
Dissertation diss1 = new Dissertation(); Dissertation diss2 = diss1; diss1.CurrentPage = 0; diss2.CurrentPage = 16; Console.WriteLine(diss1.CurrentPage); Console.WriteLine(diss2.CurrentPage);
Did you guess
16? The answer is
To understand what’s happening here, we need to understand references. They might not be obvious in this code, but learning how to use them unlocks a whole new set of superpowers in C#. This lesson explains:
This lesson uses the
Diary classes and the
IFlippable interface. Look through each file to get acquainted.
IFlippableis the interface
Bookis the base class
Diaryare classes that extend the base class and implement the interface