Codectionary / Developer documentation / C#

Choose the correct Intel or Apple Silicon .NET SDK installer, verify it in Terminal, and set up a supported editor.

Choose a supported release

Check the official .NET support policy and the installation page for your operating system before downloading. Choose a supported Long Term Support (LTS) SDK for a new learning project unless an existing project specifies another supported target. Use the newest patch for that release line. Do not treat a preview build or an end-of-support version as the default beginner choice.

At the 21 October 2026 review, .NET 10 is the supported LTS line recommended here; .NET 8 and 9 are also listed as supported but approach their November 2026 end-of-support dates. The example package name dotnet-sdk-10.0 in the Linux guide is tied to this review date. Recheck the support policy and your distribution’s package page before installing later. The SDK version you install, the target framework chosen by a project, and the runtime required to launch its output are related but not identical choices.

SDK or runtime: which do you need?

Install the .NET SDK if you want to write, build or run your own C# projects. It supplies the dotnet CLI, project templates and build tools, and includes a corresponding runtime. A runtime-only installation can execute a compatible framework-dependent app, but it does not supply the tools needed for dotnet new or dotnet build.

For a deployed app, the required runtime depends on how that app was published. A console app can use the .NET Runtime; an ASP.NET Core app needs the ASP.NET Core Runtime, which includes the base .NET Runtime. A self-contained deployment bundles what it needs instead of relying on a separately installed shared runtime. For these learning guides, select the SDK download or SDK package, not a runtime-only option.

Choose the Mac installer that matches your processor

In Terminal, uname -m reports the architecture of the current shell: normally arm64 on a native Apple Silicon shell and x86_64 on an Intel Mac. A shell running through Rosetta on Apple Silicon can report x86_64, so check About This Mac if the result is surprising. On Microsoft’s .NET download page, choose the macOS SDK installer labelled Arm64 for Apple Silicon or x64 for Intel. Check the official macOS installation page for supported macOS releases before downloading; support changes as operating systems and .NET releases age.

The architecture choice matters. On Apple Silicon, an x64 installation can exist separately for a translated process, so two dotnet commands may appear in different locations. For a normal native setup, choose Arm64 and verify the architecture shown by dotnet --info.

Terminal — identify your Mac architecture

uname -m

Install the macOS SDK

Download the official .NET SDK installer for your supported release and architecture, open the package and follow the installer. Choose the SDK area of the download page, not only the .NET Runtime area. Open a NEW Terminal window after installation and inspect the versions below.

If you already have a project, check the .NET version it targets before selecting an SDK. A newer SDK can often build older supported targets, but the application still needs the matching libraries and runtime when it runs.

  1. Check the supported .NET and macOS versions on Microsoft’s installation page.
  2. Download the macOS SDK package for Arm64 or x64 as identified above.
  3. Run the official installer, reopen Terminal and verify the SDK.

Configure a supported editor

Visual Studio Code is a supported option on macOS. Install the current macOS build from the official VS Code site, then follow its C# getting-started guide to add Microsoft’s C# tooling. Open the whole HelloCSharp project folder, not just Program.cs, so the editor can see the project file and SDK. Select the SDK-backed project if the editor asks; the terminal commands work even before you configure an editor.

Visual Studio for Mac was retired in 2024 and is not a current setup path. You do not need to install that retired IDE to write C# on macOS.

Verify from Terminal

Use dotnet --list-sdks to confirm that an SDK is installed, not merely a runtime. dotnet --list-runtimes and dotnet --info show the runtime and active architecture. command -v dotnet shows the executable that your shell finds. The architecture in dotnet --info should match the installer you intended to use.

Terminal — inspect the installation

dotnet --list-sdks
dotnet --list-runtimes
dotnet --info
command -v dotnet

Common macOS setup problems

If Terminal says dotnet: command not found, open a new Terminal window, check command -v dotnet and revisit Microsoft’s macOS PATH guidance. If the SDK appears under an unexpected x64 path on Apple Silicon, inspect dotnet --info and the macOS Arm-based-Macs section before installing more copies.

If dotnet --list-sdks is empty, install the SDK rather than another runtime-only package. If VS Code cannot find a project, open the folder containing the .csproj file and confirm the SDK works in Terminal first. If the installer refuses to run, check the operating-system support table instead of bypassing macOS security prompts.

Create and run a first project

After verifying the SDK, open a terminal in a folder where you can create files. The first command creates a new console project with Program.cs and a project file. Change into that folder, replace Program.cs with the example below, save it, then run the project. dotnet run builds the project if needed and prints the output in the terminal.

The example is a small top-level C# program, supported by modern .NET console templates. Console.WriteLine writes one line of text. If your editor still shows the template’s Hello, World! output, confirm that you saved the correct Program.cs before running again.

Terminal — create and enter a console project

dotnet new console -n HelloCSharp
cd HelloCSharp

Terminal — after replacing and saving Program.cs

dotnet run

Syntax

dotnet --list-sdks

Examples

Program.cs: a first console program

Replace the generated Program.cs with this line, then run dotnet run in the project folder. Expected output: Hello from C#!

Console.WriteLine("Hello from C#!");
  1. The quoted characters form a string containing the message. The quotes are part of C# syntax and are not printed.
  2. Console is a .NET library class. Its WriteLine method writes the string to standard output and then starts a new line; the terminal displays that output.
  3. The semicolon ends the statement. Save Program.cs, run dotnet run from the folder containing the project file, and change the message to check that your edits take effect.

Best practices

  • Choose a currently supported SDK from the official .NET site or the supported package source for your operating system.
  • Check dotnet --list-sdks before creating a project; a runtime-only installation is not enough to build C# source.
  • Keep your practice project in its own writable folder and run dotnet run from the folder containing its project file.
  • Follow your organisation’s approved installation process on a managed computer.

Runtime & versions

.NET runtime. Feature availability depends on the language and runtime version used by your project; consult the official reference below.

C# language reference

Specifications & further reading