Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Practical C# Projects with .NET
  • Table Of Contents Toc
Practical C# Projects with .NET

Practical C# Projects with .NET

By : Matt Eland
close
close
Practical C# Projects with .NET

Practical C# Projects with .NET

By: Matt Eland

Overview of this book

Too many C# developers feel stuck building the same apps day in and day out, but learning through side projects can reignite your passion and level up your skills. This book offers a practical, hands-on approach to building confidence with .NET 10 and modern C# by building a variety of engaging applications, from interactive games and productivity tools to machine learning apps and browser-based chatbots. These projects are designed to teach practical patterns and modern tooling, with a focus on learning and experimentation over production hardening. You'll work with tools like Spectre.Console, ML.NET, Uno Platform, and more, developing everything from an adventure game and a card tracker to an AI chatbot. You’ll also build modern AI-enabled systems using Ollama, Microsoft Agent Framework, OpenTelemetry, and Aspire. Written by an experienced C# engineer and teacher, this book blends technical depth with a developer-friendly tone, helping you learn faster and retain more. You'll sharpen your understanding of core .NET capabilities and gain confidence to apply them in your own work or hobby projects. By the end of this book, you'll not only have a portfolio of practical .NET apps - you’ll also have grown as a developer and rediscovered the joy of programming. *Email sign-up and proof of purchase required
Table of Contents (21 chapters)
close
close
Lock Free Chapter
1
Part 1: Building Console Applications
6
Part 2: Web, Mobile, and Desktop Applications
10
Part 3: Building AI-powered side projects
15
Part 4: Cross-platform Game Development with MonoGame
20
Index

Preface

I've had the honor of teaching and mentoring many programmers in my career and see them blossom as they grow into their journeys as developers. Almost every developer I work with goes through a stage where they say "I know how to program, but I don't know how to make things on my own and I want to learn to be better".

This is a book for people who want to grow in their craft as developers and feel they would do well to work with a series of small projects, see how they work, understand the decisions that went into making them, and learn new technologies and techniques used to build and test them.

Additionally, each one of these projects is intended not just as a polished result, but as a natural starting point for modifications and expansion, so this book becomes not just a collection of my side projects used to teach you, but new side projects you can take and expand and study without having to start fresh on your own as you grow.

It's the sincere hope of the author, the technical reviewers, and the editorial team at Packt that you find programming to be a compelling, engaging, and rewarding field and that you take joy from the projects contained in this book – and find sparks of ideas of new things to try and play with.

Who this book is for

The ideal reader will understand the basics of the C# programming language and common components of .NET. You should have comfort working with either Visual Studio or VS Code or another IDE supporting .NET. To get the most out of this book you should also understand the basics of asynchronous programming and request and response models of communications found in most web development.

If you'd like to explore the breadth of what's possible with .NET, learn new things, and most of all enjoy programming, this book is for you.

What this book covers

Chapter 1, Building an adventure game console app with .NET and Spectre.Console: In this chapter we start our journey working with small projects by building an interactive text adventure assisted by Spectre.Console's suite of additional capabilities for rich console applications.

Chapter 2, Recreating the Enigma machine with Object-Oriented Programming: If you like history or cryptography this one is for you. We'll explore an implementation of the World War II era Enigma machine and see how object-oriented programming techniques help keep applications flexible, maintainable, and testable.

Chapter 3, Exploring infinite worlds with procedural generation: Here we explore using Perlin Noise to generate a consistently random and nearly infinite game world complete with heroes and monsters.

Chapter 4, Building a Data-Driven Role Playing Game: This chapter builds off of our procedural game world from the prior chapter by adding in an old-school style RPG combat system – all driven by monster, hero, and ability data present in JSON files.

Chapter 5, Tracking collectible card games with ASP.NET minimal APIs and Entity Framework: Here we move away from the console and into web applications by building a relational database for a collectable card game in Sqlite using Entity Framework and exposing ways of interacting with it via REST endpoints and ASP.NET.

Chapter 6, Creating a trading card tracker using Blazor WebAssembly: This picks up where the last chapter left off by building a web-based front end for our card tracking application using Blazor WebAssembly and C# and connecting it to our existing REST API.

Chapter 7, Building a cross-platform chatbot with Uno Platform and ELIZA: In this chapter we recreate the first popular chatbot while exploring Uno Platform and using it to build cross-platform applications that can work on popular operating systems and mobile devices.

Chapter 8, Building conversational AI partners with Ollama and Microsoft.Extensions.AI: We begin our foray into AI by using Microsoft.Extensions.AI to connect a chat application to whatever model provider we want, and demonstrate this by running free large language models locally with Ollama.

Chapter 9, Building an AI librarian with Microsoft Agent Framework: Here we up our game by building small applications that can search a database of facts or use additional capabilities or tools to connect AI agents to new capabilities.

Chapter 10, Building and monitoring a Model Context Protocol server with Aspire: Has us exploring model context protocol by building our own MCP server, connecting our AI agent to it, and monitoring all of this activity using Aspire and OpenTelemetry.

Chapter 11, Predicting values with machine learning, IoT data, and ML.NET: This stand-alone chapter has us exploring the basics of machine learning and data science as we use collected sensor readings from internet of things devices on a campus to predict student satisfaction scores for given facility conditions.

Chapter 12, Recreating Pong in MonoGame with C#: We kick off our exploration into game development by using MonoGame to recreate the classic Pong game from the 80s while exploring the components of game development in C# with MonoGame.

Chapter 13, Building larger games with graphics, collisions, and AI: This project steps up our game development skills by building a small battle arena where space ships fly around shooting missiles at each other.

Chapter 14, Succeeding with side projects: This final chapter is not a project of its own, but rather a collection of final words of wisdom for anyone pursuing a side project of their own, and a sendoff admonishing you to get out there and build things you love.

To get the most out of this book

You should have .NET 10 installed and an editor that can edit and run .NET applications, such as Visual Studio 2026 or VS Code. You should be familiar with the C# programming language, common .NET classes, and application development terms and concepts including request / response and async / await.

Software/hardware covered in the book

Operating system requirements

.NET 10 / C# 14

Windows, macOS, or Linux

Visual Studio 2026 / VS Code

ASP .NET

Aspire

Uno Platform

Sqlite

Ollama

MonoGame

The samples in this book were designed to run on Windows, macOS, or Linux in Visual Studio 2026 or VS Code on .NET 10. You may have additional luck with other IDEs, .NET versions, or operating systems.

If you are using the digital version of this book, we advise you to type the code yourself or access the code from the book's GitHub repository (a link is available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.

Download the example code files

You can download the example code files for this book from GitHub at https://github.com/PacktPublishing/CSharp-Projects. If there's an update to the code, it will be updated in the GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Conventions used

There are a number of text conventions used throughout this book.

Code in text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, and user input. Here is an example: "This ChatTemplateSelector is then referenced by its key back where we defined our ListView"

A block of code is set as follows:

[PrimaryKey(nameof(CardId), nameof(DeckId))]
public class CardDeck {
    public required int CardId { get; set; }
    public required int DeckId { get; set; }
    public int Count { get; set; } = 1;
}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
builder.Services.AddOpenApi();
builder.Services.AddDbContext<CardsDbContext>(o =>   o.UseSqlite(builder.Configuration.GetConnectionString(               "DefaultConnection")));

Any command-line input or output is written as follows:

dotnet tool install –global dotnet-ef

Bold: Indicates a new term, an important word, or words that you see onscreen. For instance, words in menus or dialog boxes appear in bold. Here is an example: "If you're working with Visual Studio, you will also need to make sure the ASP.NET and web development workload is installed using the Visual Studio Installer."

Tips or important notes

Appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: If you have questions about any aspect of this book, email us at [email protected] and mention the book title in the subject of your message.

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/support/errata and fill in the form.

Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Practical C# Projects with .NET
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist download Download options font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon