A to Z
Glossary
Every concept in this sheet, plus the smaller terms it uses. Select a concept to open its card.
C
- Choosing a collection
List<T>keeps order and allows duplicates.- Collection expressions
- Since C# 12,
[a, b, c]creates an array, List, Span or other collection, chosen by the target type.
D
- Deferred execution
- A LINQ query does nothing when you write it.
E
- Exceptions, using and finally
- Code throws an exception for a situation it cannot handle; the nearest matching
catchup the call stack handles it. - Extension methods and extension members
- An extension method adds a method to a type you do not own, through a static class and a
thisparameter.
F
- First, Single and the OrDefault versions
Firsttakes the first match and throws if there is none.
G
- Generics and constraints
- Generics let a class or method work with any type while staying type-safe:
List<Order>only holds orders. - GroupBy and aggregates
GroupBybuckets items by a key;Sum,Count,Average,MinandMaxreduce a sequence or each group to one value.
I
- IEnumerable vs IQueryable
IEnumerableruns LINQ in memory with C# delegates.
N
- Nullable reference types
- With
<Nullable>enable</Nullable>(on in every new template)stringmeans never null andstring?means may be null.
P
- Pattern matching and switch expressions
- Patterns test the shape of a value: its type, a constant, a range or its properties.
- Primary constructors
- Since C# 12, a class can declare constructor parameters next to its name.
R
- Records
- A record is a type built for data: the compiler writes value equality, a readable ToString and, with positional syntax, an immutable constructor and properties.
V
- Value types and reference types
- A struct (int, decimal, DateTime, your own structs) is copied when you assign or pass it.
W
- Where, Select and OrderBy
- LINQ methods chain together:
Wherefilters,Selectshapes each item into something new,OrderByandThenBysort,TakeandSkippage.