Programming languages

C#

A modern object-oriented language of the .NET ecosystem: backends, desktop, Unity games.

What it is

Anders Hejlsberg created C# at Microsoft, with a first release alongside .NET Framework in 2002. It is statically typed and compiles to intermediate language (IL) that the .NET runtime executes.

Since 2014 the Roslyn compiler and the .NET platform are open source, and with .NET Core they are cross-platform: Windows, Linux, macOS. A new language version ships with .NET every year.

C# brought async / await (later borrowed by other languages), LINQ, pattern matching, records and nullable reference types. It is used in ASP.NET Core, Unity, MAUI and Azure.

Use it when

  • Backends and APIs on ASP.NET Core, especially in Microsoft-oriented companies.
  • Games on Unity.
  • Enterprise desktop and internal systems on .NET.
  • Integration with Azure and Windows.

Avoid it when

  • The team and infrastructure are fully on another stack, with no reason to switch.
  • Tiny scripts: Python or shell are quicker to write.

Key concepts

async / await
Asynchronous code in a sequential style built on Task.
LINQ
Queries over collections and databases right in the language: Where, Select, GroupBy.
Record
An immutable type with value equality, handy for DTOs.
Nullable reference types
string? annotations that make the compiler warn about possible null.
Dependency injection
A dependency container built into ASP.NET Core.

Example

A record and LINQ to filter a list.

Interview questions

  1. 1. How does a struct differ from a class?

    A class is a reference type on the heap, a struct is a value type that gets copied. Structs suit small immutable data, classes suit objects with behavior and identity.

  2. 2. How does async / await work?

    await suspends the method without blocking a thread and returns control until the operation (for example I/O) finishes. The compiler turns the method into a state machine built on Task.

  3. 3. What is LINQ?

    A set of methods and syntax for querying data sequences. The same query can run over an in-memory collection or be translated to SQL through Entity Framework.

  4. 4. What do IDisposable and using do?

    IDisposable defines releasing unmanaged resources (files, connections). A using block guarantees Dispose is called even on an exception.

Logos belong to their owners and are used for identification only. Icons: Simple Icons (CC0), Devicon (MIT).