C# Practice Exercises

DateOnly Appointment Scheduler

Calculate dates with DateOnly and DayOfWeek.

Introduction

DateOnly represents calendar dates without accidental time-zone concerns.

AddDays returns a new value because date types are immutable.

Runnable C# example

C#
Run code →
Program.cs
using System;
class Program
{
    static void Main()
    {
        var start = new DateOnly(2026, 8, 24);
        var followUp = start.AddDays(14);
        Console.WriteLine($"{followUp:yyyy-MM-dd} ({followUp.DayOfWeek})");
    }
}
Result of running the code
2026-09-07 (Monday)

Practice with the debugger

Set a breakpoint on an important assignment or condition, click Debug, and inspect the local values before stepping to the next line.

Practice with a challenge

Use what this lesson covers to solve a real problem. Each challenge runs in your browser with instant tests and an AI review.

All challenges