C#, pronounced C sharp, is a statically typed, object-oriented programming language developed by Microsoft that runs on the .NET platform. Among general-purpose programming languages, it is a mainstream choice for business applications, web services and APIs, desktop software, cloud functions and game development, valued for combining strong type safety with high productivity.
C# first appeared in 2000 as part of the original .NET Framework and is standardized as ECMA-334. Since the move to the open source, cross-platform .NET runtime, C# programs run on Windows, Linux and macOS, and the language has gained a steady stream of features drawn from functional programming, such as pattern matching, records and lambda expressions.
How C# code is compiled and executed
C# uses a two-stage compilation model. The Roslyn compiler translates source code into Common Intermediate Language (CIL), a platform-neutral bytecode stored in assemblies, usually DLL or EXE files. At run time, the Common Language Runtime (CLR) loads the assembly and its just-in-time (JIT) compiler converts CIL into native machine code for the current processor.
The runtime also provides automatic memory management through a generational garbage collector, type safety checks, exception handling and a large base class library for collections, file access, networking and text processing. Modern .NET adds tiered compilation, which first compiles quickly and later recompiles hot methods with heavier optimization, and Native AOT, which compiles ahead of time into a self-contained executable with faster startup.
| Component | Role | Practical effect |
|---|---|---|
| Roslyn compiler | Turns C# into CIL | Rich diagnostics and analyzers in the editor |
| CIL assembly | Portable compiled output | One build runs on several operating systems |
| CLR with JIT | Executes and optimizes code | Near-native speed after warm-up |
| Garbage collector | Reclaims unused memory | No manual freeing, occasional pauses |
| Native AOT | Compiles ahead of time | Fast startup, some reflection limits |
| NuGet | Package manager | Access to a large library ecosystem |
Key language features of C#
C# began close to Java in style and has since evolved into a multi-paradigm language. Its features aim to let developers express intent concisely while the compiler catches as many errors as possible before run time.
| Feature | What it does | Typical benefit |
|---|---|---|
| Generics | Type-safe reusable classes and methods | Collections without casting |
| LINQ | Query syntax over collections and data sources | Declarative filtering and grouping |
| async and await | Asynchronous code in sequential style | Responsive apps and scalable servers |
| Nullable reference types | Compiler warnings for possible null use | Fewer null reference exceptions |
| Pattern matching | Match on type, shape and values | Clear branching over complex data |
| Records | Concise immutable data types | Value equality with little code |
| Value types and spans | Stack-allocated structs and memory views | High performance without extra allocation |
The language also supports properties, events and delegates as first-class features, which shaped its strong position in user interface and component programming. A new major version typically arrives once a year together with a .NET release.
C# compared with related languages
C# is most often compared with Java, its closest relative, but also with other languages used for similar applications. The differences concern runtime model, performance profile and ecosystem more than basic syntax.
| Language | Similarity to C# | Main difference |
|---|---|---|
| Java | Managed runtime, static typing, similar syntax | Different ecosystem; C# added value types and async earlier |
| C++ | C-family syntax | Manual memory control and no managed runtime |
| TypeScript | Same original language designer, static types | Compiles to JavaScript; types erased at run time |
| Kotlin | Modern features on a managed runtime | Targets the JVM and Android first |
| Go | Garbage collected, used for services | Simpler language, native binaries by default |
| Python | General purpose, large libraries | Dynamic typing and slower execution |
Choice between them is often driven by existing platforms and skills. Organizations already running Microsoft infrastructure, Azure or Windows desktop software tend to choose C#, while teams centered on Android or the Java ecosystem lean toward Kotlin or Java.
Where C# is used
C# covers a wide range of application types through frameworks built on .NET. The language is the same everywhere; the framework determines what kind of program results.
| Application area | Framework or platform | Typical product |
|---|---|---|
| Web applications and APIs | ASP.NET Core | REST services, web portals |
| Windows desktop | WPF, Windows Forms, WinUI | Line-of-business tools |
| Cross-platform apps | .NET MAUI | Mobile and desktop clients |
| Games | Unity engine scripting | Mobile, console and PC games |
| Cloud and serverless | Azure Functions and containers | Event-driven back ends |
Its role in game development is especially notable: the Unity engine uses C# for game logic, so many developers learn the language through games before using it professionally elsewhere.
Limitations and common pitfalls
C# is mature and well supported, but it has trade-offs that matter in some projects, and several mistakes are typical of developers new to the platform.
- Garbage collection pauses and JIT warm-up can matter in latency-critical or short-lived programs; Native AOT and careful allocation help.
- Blocking on asynchronous code, for example with
.Result, can cause deadlocks and thread starvation. - Ignoring nullable warnings throws away one of the compiler’s most valuable checks.
- Overusing LINQ in hot paths can add allocations that hurt performance.
- Legacy .NET Framework code runs only on Windows and needs migration for cross-platform use.
Stripped to the essentials
C# is a language for giving instructions to computers. Microsoft created it, and today anyone can use it for free. It is strict about what kind of information each part of a program may hold. Think of a form that refuses letters in a phone number field.
That strictness means many mistakes are caught before the program ever runs. C# is used to build websites, office tools, phone apps and many video games. A large share of everyday software is written in it.
Where it is applied
A logistics company needs an internal service that calculates delivery routes and exposes them to a web dashboard and a driver app. Its team chooses C# with ASP.NET Core, because the developers already know the language and the company runs its servers in Linux containers.
The service uses async and await to query traffic data and the database without blocking threads, so one container handles hundreds of simultaneous requests. Records model route data immutably, and nullable reference types flag several missing-address cases during development. After launch, the team publishes the same code as a Native AOT build for a lightweight background job, cutting its startup time to a fraction of a second.