The Complete C# Learning Guide
C# (pronounced "C sharp") is a modern, statically typed language in the .NET ecosystem. It is used for web services, desktop software, cloud applications, and games.
How C# works
C# code is compiled to run on .NET. The compiler checks types, and the runtime manages memory for most objects while providing libraries for common application tasks.
What you will learn
You will begin with a small console program, then learn types, methods, classes, collections, exceptions, .NET libraries, and application projects.
How to use this guide
- Start with Chapter 1 and move through the chapters in order. New ideas build on the earlier ones.
- Type each example yourself, make a small change, and predict what will happen before running it.
- When a chapter is ready, its lesson will appear at the chapter link. These pages are currently blank lesson starters.
A step-by-step learning path
- Chapters 1-7: Learn the essentials. Run a console app, use typed values, read and print information, make decisions, repeat work, and write methods.
- Chapters 8-12: Model and process data. Work with arrays and collections, strings, references, resource handling, classes, structs, and records.
- Chapters 13-18: Organize dependable apps. Learn scope, namespaces and imports, assemblies and packages, files, exceptions, debugging, and tests.
- Chapters 19-24: Build practical projects. Explore algorithms, advanced C# features, safe and efficient design, the .NET toolchain, and guided projects.
C# ideas you will meet early
- .NET: the runtime and libraries that run C# applications and provide common tools for files, collections, networking, and more.
- Type: describes the data a variable can hold and the operations available for it. C# checks types when compiling.
- Method: a named operation that can take parameters and return a value. A console application begins in its entry point.
- Package: a reusable bundle of .NET code that a project can add as a dependency.
Your first C# program
In a .NET console project, put this code in Program.cs:
Console.WriteLine("Hello, world!");
Console.WriteLine writes text and then starts a new line. The string is inside quotation marks, and the semicolon ends the statement. In a terminal opened in the project folder, run:
dotnet run
Install the .NET SDK to create and run a project. For example, dotnet new console creates a starter console project; then use dotnet run inside that project's folder.
A simple way to study
- Use the type written on a variable to understand what values it can hold.
- Read the compiler message and fix the first reported error before investigating later errors.
- Practice with a small console project before moving on to web, desktop, or game frameworks.
- Run the program after small changes and add tests as soon as your code has behavior worth checking.
First file: save your program in Program.cs in a .NET console project, then run dotnet run.
Course chapters
Follow the 24 chapters in order, or choose a topic to revisit. Each chapter opens its own lesson page.
- What C# is and how a program runs
- Your first program
- Values, types, and variables
- Input and output
- Expressions and operators
- Decisions and loops
- Functions and program structure
- Collections: arrays, lists, and slices
- Strings and text
- References, pointers, and memory
- Memory and resource management
- User-defined types and data modeling
- Scope, lifetime, and visibility
- Modules, imports, and declarations
- Multi-file programs, packages, and libraries
- The standard library and ecosystem
- File input and output
- Errors, debugging, and testing
- Data structures and algorithms
- Advanced language topics
- Safety, portability, and performance
- Build systems and professional workflow
- A project ladder
- Further study checklist