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
| 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'. |