Blog
Mert Özen's blog posts on software development, backend, frontend, and DevOps.
Loops in C#: for, while, do-while and foreach
The four loops in C# and when to use each: for, while, do-while and foreach. break and continue, a clean way out of nested loops, the infinite loop pattern, and why changing a collection while walking it throws an exception.
Conditions in C#: if/else, switch and Switch Expressions
The ways to make decisions in C#: why order matters in an if/else chain, braces and scope, a switch statement that forbids fall-through, the value-returning switch expression, and the relational and logical patterns of C# 9.
Operators and Expressions in C#: Short-Circuiting, ??, ?. and Precedence
Expressions versus statements in C#, arithmetic and compound assignment, prefix and postfix increments, comparison, logical operators and short-circuiting, the ?: operator, handling null with ??, ??= and ?., and precedence traps such as 100 - discount ?? 0.
Type Conversions in C#: Cast, Parse, TryParse and Convert
Implicit and explicit conversions in C#, how a cast truncates and overflows, when to use Parse and when TryParse, Convert's rounding and null behavior, culture-dependent parsing that silently multiplies prices by a hundred, and a first look at boxing and unboxing.
Strings in C#: Interpolation, StringBuilder and the Turkish I Trap
Immutability of strings in C#, interpolation and format specifiers, escape sequences and verbatim strings, commonly used methods, the measured memory difference with StringBuilder, StringComparison and the Turkish I/ı/İ trap.
Numbers and Arithmetic in C#: int, double, decimal and Overflow
Integer division and the remainder in C#, choosing between int, long, double and decimal, why 0.1 + 0.2 isn't 0.3, decimal for money, overflow and checked, dividing by zero, the Math class and the banker's rounding trap.
Variables and Data Types in C#: var, const and Literals
Statically typed variables in C#, the sizes and ranges of the built-in types, what var really does, literal suffixes and the compiler errors around them, const and C# 10's constant interpolated strings, default values and .NET naming conventions.
Installing C# and Your First Program: dotnet new console and the Project File
Installing the .NET 10 SDK, the first project with dotnet new console, top-level statements and the Main the compiler generates, TargetFramework, ImplicitUsings, Nullable and LangVersion in the csproj, dotnet run and build, choosing an IDE, and reading your first compiler error.
What Are C# and .NET? Language, Platform and Versions
The line between C# and .NET: the compiler, IL and JIT, the CLR, the BCL, SDK versus runtime, the move from .NET Framework to .NET, the LTS/STS support calendar, how C# and .NET versions pair up, and the plan for the seven-series C# family.