Introduction to C# Tutorial:
Welcome to the C# Station Tutorial This is a set of lessons suited for beginning to intermediate programmers or anyone who would like to gain familiarity with the C# programming language. These lessons will help you get a quick head-start with C# programming.
Set up a console project with .NET 10
Install the .NET 10 SDK using Microsoft’s instructions for Windows, macOS, or Linux. Choose a supported operating system and the SDK for your machine’s processor architecture. The SDK contains the compiler and runtime needed for these console examples. A text editor is enough for the command-line path; an IDE is optional.
Open PowerShell or Command Prompt on Windows, or a terminal on macOS or Linux. Run:
dotnet --list-sdks
dotnet new console --framework net10.0 --name CSharpStationWelcome
cd CSharpStationWelcome
Confirm that the SDK list includes a 10.0 SDK. Replace all of Program.cs with this program and save it:
using System;
class WelcomeCSS
{
static void Main()
{
Console.WriteLine("Welcome to the C# Station Tutorial!");
}
}
dotnet run
Welcome to the C# Station Tutorial!
For each lesson, replace Program.cs with one complete example at a time. The current template uses top-level statements, while the older lessons teach an explicit class and Main. Replacing the file avoids combining the two entry-point styles.
If dotnet is not found, reopen your terminal after installation and check the SDK installation instructions. If the project cannot target net10.0, check the active SDK with dotnet --version and any global.json file in the directory or its parents.
Continue to Lesson 1 for program structure, command-line arguments, and interactive input. You can reuse this project by replacing Program.cs with the lesson listing; skip creating the separate Welcome project in Lesson 1 if you do so. The lesson table below keeps the original sequence and legacy URLs. The code ZIP links are historical downloads; the examples displayed in each lesson are the starting point for the current SDK workflow.
Microsoft also provides a console app tutorial for an editor-based workflow.
This tutorial is a work in progress. Its quality is a product of volunteer reviews and valuable feedback received from many readers. Please visit periodically for the latest updates and new lessons.
Once you’ve completed this tutorial, you may be interested in additional resources to continue learning C#. There are also additional Articles on this site.
I hope you enjoy the C sharp tutorial and best of luck!
Joe
Follow Joe Mayo on Twitter.
References:
C# Language Reference and Specifications
Standard ECMA-334 C# Language Specification
C Sharp Tutorial Lessons:
The legacy ZIP downloads are currently unavailable. Open each lesson below to follow its examples.
| [html] | Lesson 01: Getting Started |
| [html] | Lesson 02: Expressions, Types, and Variables |
| [html] | Lesson 03: Control Statements – Selection |
| [html] | Lesson 04: Control Statements – Loops |
| [html] | Lesson 05: Methods |
| [html] | Lesson 06: Namespaces |
| [html] | Lesson 07: Introduction to Classes |
| [html] | Lesson 08: Class Inheritance |
| [html] | Lesson 09: Polymorphism |
| [html] | Lesson 10: Properties |
| [html] | Lesson 11: Indexers |
| [html] | Lesson 12: Structs |
| [html] | Lesson 13: Interfaces |
| [html] | Lesson 14: Introduction to Delegates and Events |
| [html] | Lesson 15: Introduction to Exception Handling |
| [html] | Lesson 16: Using Attributes |
| [html] | Lesson 17: Enums |
| [html] | Lesson 18: Overloading Operators |
| [html] | Lesson 19: Encapsulation |
| [html] | Lesson 20: Introduction to Generic Collections |
| [html] | Lesson 21: Anonymous Methods |
| [html] | Lesson 22: Topics on C# Type |
| [html] | Lesson 23: Working with Nullable Types |