CodeBlanks Logo Icon CodeBlanks

Project design

C# course · Beginner · Lesson 112/116

Design the skeleton of the beginner final mini app.

Project: Book list

In this project you will build a small book list application as the capstone of the beginner level. Each lesson adds a piece, and the final lesson brings everything together. The first lesson sets up the program skeleton and menu.

The app will show a menu: 1 - Add, 2 - List, 3 - Exit. In this step you only define a PrintMenu method that prints the menu and call it from Main. Later lessons will add adding books, listing, and error handling.

Calling the PrintMenu method

After defining a method, you call it inside Main. The call is the method name followed by empty parentheses: PrintMenu();. When the program runs, the menu is printed.

Defining a method and calling it are different. Definition tells what the method does; a call runs it. In this project you define PrintMenu once and can call it many times, which is the main advantage of methods.

Exercise Set up the menu skeleton

Define a method called PrintMenu with three Console.WriteLine calls: "1 - Add", "2 - List", "3 - Exit". Then call PrintMenu(); inside Main.

Show example solution
Define the PrintMenu method with three WriteLine calls, then add PrintMenu(); in Main.
Example solution:
using System;

class Program
{
    static void PrintMenu()
    {
        Console.WriteLine("1 - Add");
        Console.WriteLine("2 - List");
        Console.WriteLine("3 - Exit");
    }

    static void Main()
    {
        PrintMenu();
    }
}

Test yourself

  1. Why put the menu in a separate method?

    static void PrintMenu() { ... }
    • To make code reusable and organised
    • Because it runs faster
    • Because it is required
    • Because it uses less memory
    Show answer

    To make code reusable and organised — Correct! Methods make code reusable and organised.

  2. Add the menu line

    static void PrintMenu()
    {
        Console.WriteLine("1 - Add");
        Console.WriteLine("2 - List");
        ____;
    }
    Show answer
    static void PrintMenu()
    {
        Console.WriteLine("1 - Add");
        Console.WriteLine("2 - List");
        Console.WriteLine("3 - Exit");
    }
  3. Match each menu item with its description

    1 - Add
    Add a book
    2 - List
    Show books
    3 - Exit
    Quit the program

All lessons in Beginner