C# is a modern, object-oriented programming language developed by Microsoft as part of its .NET initiative, first released in 2000 and currently at version 14 (2026, .NET 10). It combines type safety and garbage collection with fine-grained control when needed, running on the Common Language Runtime (CLR) which provides cross-platform support. The language has evolved significantly with features like async/await, LINQ, pattern matching, nullable reference types, and now extension members that prioritize developer productivity and code safety. Think of C# as a strongly-typed, garbage-collected language where you rarely manage memory manually but gain full low-level control via unsafe contexts, Span<T>, and stackalloc — understanding this balance between safety and performance is key to mastering the language.
What This Cheat Sheet Covers
This topic spans 28 focused tables and 316 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
Table 1: Value Types and Built-in Types
These are the primitive building blocks you reach for first — the integers, floating-point numbers, characters, and booleans that map to fixed amounts of memory. The trick is picking the right one: int and double cover most cases, but decimal exists for money where rounding errors are unacceptable, and the size-specific types matter when range or precision is on the line.
| Type | Example | Description |
|---|---|---|
int x = 42; | • 32-bit signed integer • range -2,147,483,648 to 2,147,483,647 • most common integer type. | |
long y = 9_223_372_036_854_775_807L; | • 64-bit signed integer • use L suffix for literals• for values exceeding int range. | |
double pi = 3.14159; | • 64-bit floating-point • default for decimal literals • ~15–17 digits precision. | |
float f = 3.14f; | • 32-bit floating-point • requires f suffix• ~6–9 digits precision. | |
decimal price = 19.99m; | • 128-bit high-precision • requires m suffix• 28–29 digits precision • ideal for financial calculations. | |
bool isValid = true; | • Boolean type; only true or false• no implicit conversion from integers. | |
char c = 'A'; | • Single 16-bit Unicode character • use single quotes • supports escape sequences like '\n'. |