Released · improving
Programming language · Since 2000
C# is an object-oriented language from Microsoft for building web, desktop, game and cloud applications on .NET with a single language.
C# is a general-purpose programming language that Microsoft introduced in 2000. It is statically typed and object-oriented at its core, and over time it has adopted functional and asynchronous features such as generics, LINQ, async/await and pattern matching. Both the compiler (Roslyn) and the .NET runtime are developed as open source and run on Windows, macOS and Linux.
C# is used across many fields: web APIs and services built with ASP.NET Core, Windows desktop applications, game development with Unity, and cloud back ends. A broad base class library and the NuGet package registry let you handle common tasks such as database access, serialization and logging with well-tested libraries. Memory is managed by a garbage collector, yet value types and features like Span<T> let you write performance-sensitive code as well.
The easiest way to start is to install the .NET SDK and create a console project with the dotnet command. The C# documentation on Microsoft Learn includes a language tour and step-by-step tutorials that take you from basic syntax through object-oriented programming, LINQ and async code. For an editor, Visual Studio or Visual Studio Code with the C# Dev Kit extension gives you code completion and debugging out of the box.
Generics, type inference with var and nullable reference types catch many errors at compile time while keeping code concise.
LINQ queries collections and databases with the same syntax, and async/await makes asynchronous code read like sequential code.
A garbage collector manages memory, while structs, Span<T> and ref let you write high-performance code that avoids unnecessary allocations.
The same code runs on Windows, macOS and Linux, backed by a rich base class library and the NuGet package ecosystem.
Download the .NET SDK installer for your operating system from dotnet.microsoft.com and run it. On Windows you can also use winget, and on Linux your distribution's package manager. The SDK includes the compiler, the runtime and the dotnet command-line tool.
Open a new terminal and check that the installed SDK version is printed. If several versions are installed, dotnet --list-sdks shows the full list.
dotnet --versionCreate a new project from the console app template, then build and run it right away. The hello folder will contain the project file hello.csproj and the source file Program.cs.
dotnet new console -o hello && cd hello && dotnet runThis code uses top-level statements, so the compiler generates the entry point for you without an explicit class or Main method. Console.WriteLine writes a line of text to standard output. The console app template imports common namespaces implicitly, so it works without using System;, and dotnet run builds and runs the program in one step.
Program.cs
Console.WriteLine("Hello, world!");
dotnet runSix chapters that take you from installation to the core ideas of C#.
Ask questions, share experience and trade opinions about C#.
No discussions yet. Start the first one.
0 comments
Sign in · Sign in to leave a comment.
Be the first to comment.