Skip to main content
BRILLIQS

C#

A statically typed language from Microsoft, used with the .NET platform for applications, services and tooling.

C# is a programming language developed by Microsoft for the .NET platform. It is statically typed, meaning types are checked before the program runs, and it is object oriented while including features from other styles. It is used for web services, desktop applications, games and command line tools across the platforms .NET supports.

A language and the platform under it

C# is a language. .NET is the platform it runs on, supplying the runtime that executes compiled code and the libraries that provide most of what a program needs.

The distinction is worth keeping in mind because discussions frequently blur them. Other languages target .NET, and in practice the large majority of .NET development is in C#, which is why the two names appear together so often.

Types checked before anything runs

C# is statically typed. Every value has a type known at compile time, and the compiler checks that values are used consistently with it.

Passing a string where a number is expected does not produce a runtime failure. It produces a compile error, with a location, before the program exists in runnable form.

The trade is familiar. Types are stated in the code, which is more to write than a language that infers everything or checks nothing. What is bought is that a category of mistake cannot reach execution, and that tooling knows enough about the code to assist accurately.

For software that is long lived and worked on by several people, that trade has generally been judged worthwhile, which is why languages in this family dominate enterprise application development.

Querying inside the language

Language integrated query is one of the more distinctive features.

Filtering a collection, projecting fields from it and grouping it are expressed in syntax that is part of the language rather than as loops that build up results.

The value is in what the code says. A loop with an accumulator and a conditional describes how to compute a result. A query describes what result is wanted. The second is easier to read six months later, and easier to be confident about.

The same syntax extends through providers to other data sources, including databases, so a query written in the language can be translated into one sent elsewhere. That translation has limits worth understanding, since not everything expressible in the language translates to every source.

Waiting, written in order

Operations that take time, network calls, database queries, file access, are handled with asynchronous constructs built into the language.

The significance is how the code reads. Without language support, waiting is expressed by supplying code to run when something completes, which inverts the order of the program relative to the intent.

Here, an asynchronous operation is written in sequence with the keywords marking where waiting occurs. The code reads in the order the work happens, while not blocking the thread that runs it.

This makes concurrent code substantially easier to write correctly, which matters because concurrency is where subtle problems concentrate.

Where it runs

The historical association with Windows is real and out of date.

Current .NET versions run on Windows, Linux and macOS, and deploying .NET applications in Linux containers is entirely ordinary.

Some older frameworks and libraries remain Windows specific, particularly for desktop interfaces, and the official documentation identifies which. For new server side work the platform question is generally settled.

What it is used for

Web services and applications. The most common use, building interfaces and applications served over the network.

Business applications. Internal software in organisations already using Microsoft technology, where the surrounding tooling and identity arrangements align.

Games. Game engines using it as their scripting language make it widely used in that industry, which is a substantial community with quite different concerns from business software.

Tooling. Command line utilities and automation, running across supported operating systems.

Who uses it

C# is used by application developers, particularly in organisations with Microsoft technology in place, and by game developers working with engines that adopt it. It is a mainstream choice for business software with a large body of practitioners.

Points to consider

C# and .NET are developed by Microsoft with open source components, and the official documentation is the reference for the language, the platform and their versions.

Versions matter more than usual here, because the platform's history includes a significant transition from the older Windows only framework to the current cross platform one. Material found online may describe either, and establishing which applies is worth doing before following it.

The language has accumulated a great deal of capability over its versions. That is mostly a benefit and it means there are usually several ways to express something, which places some responsibility on teams to agree conventions.

Static typing costs some verbosity relative to dynamically typed languages. Type inference reduces this and does not remove it.

Getting started

The official documentation covers the language, the platform and building each kind of application. Writing a small web service is the most direct route in, because it exercises the type system, the asynchronous constructs and the library facilities in one short exercise.

Key features of C#

Capabilities described in the official documentation.

Types checked before running

The compiler verifies that values are used consistently rather than leaving it to execution.

Language integrated query

Collections and data sources are queried using syntax that is part of the language itself.

Built in asynchronous constructs

Operations that wait are written in a sequential style using keywords the language provides.

Runs on several operating systems

Current .NET versions run on Windows, Linux and macOS rather than Windows alone.

Advantages of C#

Factual advantages that follow from the features above.

Mistakes surface at compile time

Static typing means inconsistent use of values is reported before the program is run.

Querying reads clearly

Query syntax in the language expresses filtering and grouping without dropping into loops.

Asynchronous code stays readable

Language support means waiting operations are written in an order that matches the intent.

One language across application types

Web services, desktop software and tooling are written in the same language on one platform.

Common use cases for C#

Situations the official documentation describes this tool as being used for.

Financial services

Building web services

Application programming interfaces and web applications are written and served on .NET.

Manufacturing

Developing internal business applications

Line of business software is built for organisations already using Microsoft technology.

Gaming

Writing games

Game engines that use it as their scripting language make it common in game development.

Technology

Creating command line tooling

Utilities and automation are written and run across the operating systems .NET supports.

Official website

Everything on this page is based on the official documentation for C#. You can read the source here.

C# official documentation

Frequently asked questions about C#

Answers taken from the official documentation for this tool.

That the type of every value is known and checked when the code is compiled rather than when it runs. Using a value in a way inconsistent with its type is a compile error. This catches a category of mistake before the program executes, at the cost of stating types in the code.

Historically it ran on Windows. Current .NET versions run on Windows, Linux and macOS, and .NET applications are commonly deployed in containers on Linux. Some older frameworks and libraries remain Windows specific, which the official documentation identifies.

Query syntax built into the language for filtering, projecting and grouping collections. It applies to in memory collections and, through providers, to other data sources. The value is expressing such operations declaratively rather than as loops with accumulating variables.

C# is a language; .NET is the platform it runs on, providing the runtime and the class libraries. Other languages also target .NET. In practice most .NET development is done in C#, so the two are frequently discussed together.