C# Fundamentals: A Beginner’s Guide to C# 15 and .NET 11 with Practical Examples and Exercises

C# Fundamentals: A Beginner’s Guide to C# 15 and .NET 11 with Practical Examples and Exercises

13+

Learn C# 15 and .NET 11 through small programs, Visual Studio debugging, exercises, and the Student Tracker project.

0 followers
42 chapters
Software & AI Development
2026
You're viewing a limited preview. Create a free account to read free books or get Premium to unlock the entire library.

Chapter 1: Welcome to C# 15 and .NET 11

What You Will Learn

  • Distinguish the C# language from the .NET runtime, libraries, and SDK
  • Know where the book covers the newest C# features
  • Follow the book's sequence of examples, quizzes, and activities
  • Recognize the tools needed to build a console program

Prerequisites

  • None. You do not need any programming experience.

Concept Overview

Welcome to Modern C#

Your first C# program prints one line of text: Hello, World!. You will change that line, run the program again, and see your change. Every chapter works the same way: write a little code, run it, and look at what it prints. All the programs in this book are console programs, which run in a text window, read what you type, and print lines of text.

A program is a list of instructions for the computer, and C# is a language for writing them. The C# you write is called source code. .NET is the platform that turns source code into a running program. It has three parts you will hear about:

  • The SDK (software development kit): the tools that build your program.
  • The runtime: the part that runs your finished program.
  • The libraries: ready-made code for jobs such as reading files or storing data.

The same platform also builds web, desktop, mobile, and cloud applications. Figure 1.1 shows how the three parts work together on your first program.

Figure 1.1. You write source code in a file such as Program.cs. When you type dotnet run, the .NET SDK builds your program, and the .NET runtime runs it with ready-made code from the .NET libraries.

Chapter 2 installs the tools before Chapter 3 asks you to write code.

Why C# Still Matters

C# reads clearly enough for beginners, and professional teams use the same language and tools for large applications. C# also catches many mistakes before your program runs. The compiler, the SDK tool that turns your source code into a program, reports each mistake it finds. Your program does not run until you fix them.

The examples start small. Each new concept solves a problem you can see in a running program.

Step-by-Step Implementation

There is nothing to type in this chapter yet. These sections explain what the book covers and how each chapter works. The Full Example previews the Visual Studio project and the alternative terminal commands in Chapter 2.

What Is New in C# 15 and .NET 11

This edition uses C# 15 and .NET 11, the newest versions. You do not need any new feature to start. A few short sections marked C# 15 appear in Chapters 6 and 13. Part VIII (Chapters 23 to 26) covers recent features from C# 14 and C# 15 once you know the basics. Chapter 26 is optional.

How This Book Is Structured

Each chapter introduces a topic, demonstrates it in code, and gives you a quiz and an activity to check your understanding. Chapters 2 and 3 include screenshots so you know what the download page, the terminal, and the editor look like, and Chapters 16 and 19 show a crash and a test run the same way. Diagrams show how the code works; the steps themselves stay in text so they read well on Kindle and other devices.

Most examples are separate console lessons you can rerun on their own. Most chapters from 3 to 22 also add a step to one program you keep: the Student Tracker. If you are reading on Kindle, keep a laptop open so you can type along as you go.

Who Should Read This Book

If you're new to programming, work through the chapters in order and run the examples before attempting each activity. Readers coming from another language can use the quizzes to check familiar ideas. Even so, run the C# examples with the book's tools.

Getting Ready

Have a supported Windows, macOS, or Linux computer, an internet connection, and permission to install the .NET 11 SDK. On Windows, use Visual Studio 2026 for the main walkthroughs. Its editor, Solution Explorer, debugger, and Test Explorer support the lessons. VS Code with C# Dev Kit is the alternative on Windows, macOS, and Linux. A terminal, a window for typing commands, provides the matching .NET CLI commands. Chapter 2 shows both setups; Chapter 3 starts a hands-on debugger lesson.

Full Example

In Chapter 2, Step 4, you create a C# Console App named HelloWorld in Visual Studio and press Ctrl+F5 to run it. The VS Code alternative uses these three terminal commands to create and run the same program:

dotnet new console -n HelloWorld -f net11.0
cd HelloWorld
dotnet run

dotnet new console creates a project: a folder named HelloWorld with the files for one program. cd HelloWorld moves into that folder, and dotnet run builds the program and runs it. You should see:

Hello, World!

If you see Hello, World!, your tools work. The message comes from the one line of code in the project's Program.cs file:

Console.WriteLine("Hello, World!");

Console.WriteLine writes the text between the quotation marks to the console, the window your program runs in. Chapter 3 explains this line; you do not need to change anything yet.

Common Mistakes

  • Install the SDK when you want to build programs. A runtime-only installation can run existing applications but cannot build these exercises.
  • Create every project from CSharpBook, the exercise folder Chapter 2 sets up, not from inside another project's folder. A project inside another project breaks the outer one. The outer project then fails to build with errors such as CS8802: Only one compilation unit can have top-level statements. Type cd .. to go back to CSharpBook first.

Start with a working console program.

Performance and Production Considerations

Keep each lesson in its own project folder. Then a mistake in one lesson cannot stop another lesson from building.

Choose language features for clarity. A new feature is useful when it makes the particular program easier to understand, not merely because it is new.

Run the example before changing it.

Summary

C# describes program logic. .NET supplies the runtime, libraries, and SDK. This book builds practical skills through small runnable lessons, then introduces newer language features when their prerequisites are in place.

Key Terms

  • C# 15: The C# language version used throughout this book with the .NET 11 platform.
  • .NET 11: The runtime, libraries, and SDK targeted by this edition.
  • SDK: Software Development Kit that includes compilers and tools for building programs.
  • Source code: The C# you write, which the compiler turns into a program.
  • Compiler: The SDK tool that turns your C# source code into a program and reports mistakes before it runs.
  • Runtime: The part of .NET that runs your finished program.
  • Library: Ready-made code your program can use, such as code for reading files.
  • Console program: A program that runs in a text window, reads what you type, and prints lines of text.
  • Project: A folder that holds the files for one program.

Mini Quiz

1. What two main technologies form the foundation of modern C# development?

A. Python and Visual Basic

B. Java and Node.js

C. HTML and CSS

D. C# and .NET

2. You have C# source code but only installed the .NET runtime. What do you need to build the book's projects?

A. Manual memory-management software

B. The .NET SDK, which supplies build tools

C. A different operating system for every chapter

D. A larger monitor

3. The Program.cs file in the Full Example contains Console.WriteLine("Hello, World!");. What is this example showing?

A. A declaration of a new .NET runtime

B. A command that installs Visual Studio

C. A line that writes a message to the console

D. A database command

4. How is this book structured to help you learn effectively?

A. It presents every concept only in theory

B. It uses hands-on examples and mini quizzes in each chapter

C. It focuses only on advanced enterprise features

D. It relies heavily on screenshots and diagrams

5. Why is C# considered both beginner-friendly and capable for large projects?

A. It is only used for small hobby applications

B. It combines clear, readable code with professional-grade tools and libraries

C. It requires deep knowledge of computer hardware

D. It is easy to learn but lacks modern features

Answers are provided in the Answer Key at the end of the book.

Activity

Identify Your Tools

  • Identify your computer's operating system and the .NET 11 SDK download for it. Chapter 2, Step 1 shows how to tell which download you need.
  • Explain, in one sentence each, what the language, runtime, and SDK do.
  • Complete Chapter 2 through Step 4, which runs the Full Example above from inside your CSharpBook folder.
  • In Visual Studio open the generated Program.cs in Solution Explorer (Chapter 2, Step 4) and replace Hello, World! inside the quoted message with your own greeting. Save and press Ctrl+F5 to check the changed output. VS Code alternative: open Program.cs in its Explorer, save, and run dotnet run from the project folder.
  • Challenge: In the project folder, type dotnet --version to see which SDK version the project uses. Then type dotnet --list-sdks. It lists every SDK installed on your computer, one per line: the version, then the folder it is in, such as 11.0.100 [C:\Program Files\dotnet\sdk] on Windows.

Enjoying this book?

Create a free account to leave comments, track your progress, and more!

Read and listen on the go with the unQbd app. Get the app
An unhandled error has occurred. Reload 🗙

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please reload the page.