CodeBlanks Logo Icon CodeBlanks

Class design

C# course · Intermediate · Lesson 19/116

Design the skeleton of the helper library class.

Project: Helper library

In this 5-lesson project you will build a reusable helper library. Each lesson adds one piece, and by the final lesson you will have a working module. All helpers live inside one static class Helpers.

You will use what you learned in previous groups: classes, constructors and inheritance. Static classes are called without creating an instance: Helpers.Capitalize("hello"). That is why helper libraries are designed as static classes.

Static class rules

A static class has three key traits: it cannot be instantiated (new Helpers() is a compile error), all its members must be static (fields, methods, properties), and it cannot inherit or be inherited.

These constraints are ideal for helper libraries. You declare Helpers once; everywhere you call Helpers.MethodName. No need to hold an instance, manage memory, or set up dependencies.

Exercise Define the Helpers static class

Declare a static class Helpers (empty body for now). Inside Main print "Ready" with Console.WriteLine.

Show example solution
Define the class with static class Helpers { }. In Main write Console.WriteLine("Ready");
Example solution:
using System;

static class Helpers
{
}

class Program
{
    static void Main()
    {
        Console.WriteLine("Ready");
    }
}

Test yourself

  1. Which is a static class declaration?

    • class Helpers { }
    • static class Helpers { }
    • static Helpers() { }
    • Helpers static { }
    Show answer

    static class Helpers { } — Correct. static class Helpers { } is a static class declaration.

  2. Complete the static class

    static ____ Helpers { }
    Show answer
    static class Helpers { }
  3. Match each keyword to its role

    static
    Makes the class static
    class
    Declares a class
    void
    No return value
    public
    Access from anywhere

All lessons in Intermediate