Example – book reader

As an example, you will prepare a simple application that allows a user to read a book by changing the pages. One should be able to move to the next page (if it exists) after pressing the N key, and go back to the previous page (if it exists) after pressing the P key. The content of the current page, together with the page number, should be shown in the console, as presented in the following screenshot:

Let's start with the declaration of the Page class, as shown in the following code:

public class Page 
{ 
    public string Content { get; set; } 
} 

This class represents a single page and contains the Content property. You ...

Get C# Data Structures and Algorithms now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.