Set up your local environment
The first step in running a tutorial on your machine is to set up a development environment.
- We recommend Visual Studio for Windows. You can download a free version from the Visual Studio downloads page. Visual Studio includes the .NET SDK.
- You can also use the Visual Studio Code editor with the C# DevKit. You'll need to install the latest .NET SDK separately.
- If you prefer a different editor, you need to install the latest .NET SDK.
Basic application development flow
The instructions in these tutorials assume that you're using the .NET CLI to create, build, and run applications. You'll use the following commands:
dotnet new
creates an application. This command generates the files and assets necessary for your application. The introduction to C# tutorials all use theconsole
application type. Once you've got the basics, you can expand to other application types.dotnet build
builds the executable.dotnet run
runs the executable.
If you use Visual Studio 2019 for these tutorials, you'll choose a Visual Studio menu selection when a tutorial directs you to run one of these CLI commands:
- File > New > Project creates an application.
- The
Console Application
project template is recommended. - You will be given the option to specify a target framework. The tutorials below work best when targeting .NET 5 or higher.
- The
- Build > Build Solution builds the executable.
- Debug > Start Without Debugging runs the executable.
Pick your tutorial
You can start with any of the following tutorials:
Numbers in C#
In the Numbers in C# tutorial, you'll learn how computers store numbers and how to perform calculations with different numeric types. You'll learn the basics of rounding and how to perform mathematical calculations using C#.
This tutorial assumes that you have finished the Hello world lesson.
Branches and loops
The Branches and loops tutorial teaches the basics of selecting different paths of code execution based on the values stored in variables. You'll learn the basics of control flow, which is the basis of how programs make decisions and choose different actions.
This tutorial assumes that you have finished the Hello world and Numbers in C# lessons.
List collection
The List collection lesson gives you a tour of the List collection type that stores sequences of data. You'll learn how to add and remove items, search for items, and sort the lists. You'll explore different kinds of lists.
This tutorial assumes that you have finished the lessons listed above.