Loading...

Install C#

Put the .NET SDK on the computer so the file from the introduction can actually run. Install the SDK, open a new terminal, read a version line from dotnet --version, create a small PineLab folder, keep Console.WriteLine("pine"); in the program, and run dotnet run so the screen shows pine. Finished looks the same on Windows, macOS, and Linux once the commands work. The clicks before those commands differ by system — do the section that matches the computer in front of you, then come back to the shared run. Leave reading every line of the program for the next page. This lesson is the install and the first successful run, not an ASP.NET site.

What you are installing

The download is the .NET SDK. SDK is the kit that contains the dotnet command this course uses to create a project and run it. A computer with only the runtime can run some apps and still fail this page, because dotnet new and the teaching dotnet run habit need the SDK. You do not type the letters SDK into the terminal as a magic word. You install the kit, and the kit adds dotnet.
Get the kit from the official .NET download page on Microsoft’s site (dotnet.microsoft.com). Choose the SDK, not a runtime-only package. For this course take version 8 or newer. A long-term release such as 8 or 9 is fine. A higher current SDK number is fine when the page offers it. Do not stop at a runtime-only installer when the page also offers the SDK. The small numbers after the dot are the patch. One computer might show 8.0.10 and another 8.0.12. Both are fine when the major number is 8 or higher.

Windows

On Windows download the SDK installer for your chip (x64 on most PCs). Open the installer and let it finish. Leave options that add dotnet to PATH turned on when the installer shows them. PATH is the list of folders Windows searches when you type a command. If the SDK folder is missing from that list, a terminal will say it cannot find dotnet even though files exist on disk.
A terminal that was already open cannot see a PATH change. Close every Command Prompt and PowerShell window you had open before the installer finished. Open a new window. Type dotnet --version and press Enter. The screen writes a version line that contains 8 or a higher major number. If the new window cannot find dotnet, open a newer window after a finished SDK install with PATH left on, or run the installer again and keep PATH enabled. Do not continue to PineLab while dotnet is missing.

macOS

On macOS download the SDK installer that matches the chip. Apple silicon Macs use the arm64 package. Older Intel Macs use the x64 package. Open the .pkg and finish Install. Quit Terminal if it was already open, then open Terminal again. An old window can still say the command is missing.
In the new Terminal type dotnet --version. The screen writes a version line with 8 or a higher major number. If the command is still missing, finish the .pkg again, open a new Terminal, and type dotnet --version once more. A dialog that offers some other Java-style helper is not this kit — close it and use the .NET SDK package from the official download page.

Linux

On Linux install the .NET SDK package the way your distribution installs other packages, using the package kind the download page lists for your system. When the package install finishes, open a new terminal. Type dotnet --version. The screen writes a version line with 8 or a higher major number. If the terminal cannot find dotnet, finish the package install, open a new window, and type the version command again. The shared project steps below are the same after the version line works.

Create PineLab and run pine

The version line does not write pine. It only proves the SDK is installed. pine comes from the program. In the new terminal, move to a folder you control, then create a console project:
dotnet new console -n PineLab -o PineLab --use-program-main
Enter the folder:
cd PineLab
Open Program.cs and keep this teaching shape — public class Pine, Main, and one writing line:

PineLab Program.cs writes pine

csharp
using System;

public class Pine
{
    public static void Main()
    {
        Console.WriteLine("pine");
    }
}

Save the file. In the same PineLab folder type:
dotnet run
The screen shows pine. One line. No quotes. No second line. The class name Pine is not the screen word. The writing line is Console.WriteLine("pine");, the same idea as the introduction file, now executed after a real install.
If dotnet run cannot find a project file, confirm you are inside PineLab where the .csproj file lives. If the screen shows something other than pine, open Program.cs and restore the writing line with "pine" between the quotes. Reinstalling the SDK does not fix a wrong folder.

Command habits after install

Keep version proof and the pine run as two separate checks.

📊 Install C# command habits

What you type Screen
dotnet --version a version line, 8 or higher
dotnet new console -n PineLab -o PineLab --use-program-main creates the lab folder
dotnet run (inside PineLab) pine
New terminal after install required so PATH changes are visible
SDK not runtime-only needed for dotnet new and this run habit

Install is not First Program yet

The next page opens the program lines one at a time and teaches which line writes the screen. This page only needs the SDK installed and one successful dotnet run that shows pine. Do not invent ASP.NET hosting here. Do not skip the new-terminal rule after PATH changes. Do not treat a runtime-only install as finished when dotnet new fails.
Without dotnet --version, you have not proved the SDK. Without dotnet run showing pine, you have not finished the lab on this page. Keep both checks. Keep leftover Java javac / java Mint habits off this C# install — the teaching command here is dotnet.

Before First Program

You can install the .NET SDK 8 or newer, open a new terminal, read dotnet --version, create PineLab with dotnet new console ... --use-program-main, keep Console.WriteLine("pine");, and run dotnet run so the screen shows pine. The table separates version proof from the pine run. The next page is C# First Program.
Keep the PineLab folder for a clear first run. Keep ASP.NET templates off this page when you practice install. Keep running from the wrong folder off this page. Those habits are the checkpoint before First Program. When the version line shows 8 or higher and dotnet run shows pine, Install C# did its job and you are ready for First Program if you continue.
One last pass: SDK installed, new terminal used, dotnet --version readable, PineLab folder present, writing line still "pine", dotnet run prints pine, no web host required. Prefer one clear install path per computer so each pass teaches the same map from download to pine.

🧠 Test Your Knowledge

Ready to Start

Test Your Knowledge

Challenge yourself with this interactive quiz and see how well you understand the topic

❓
5
Questions
🎯
70%
To Pass
♾️
∞
Time
🔄
∞
Attempts

📝 Instructions

  • Read each question carefully
  • Select the best answer for each question
  • You can retake the quiz as many times as you want
  • Your progress will be shown at the top