-
Book Overview & Buying
-
Table Of Contents
Practical C# Projects with .NET
By :
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.
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.
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.
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.
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!
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.
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.