pattern matching: practical reference
pattern matching: practical reference: C# patterns test type, value, and structure and can bind variables.
CKTIS / C#
Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.
pattern matching: practical reference: C# patterns test type, value, and structure and can bind variables.
performance and complexity: practical reference: Performance covers time, allocations, I/O, concurrency, and data characteristics.
program entry point: practical reference: The entry point starts the process, receives arguments, and establishes the exit code.
records and equality: practical reference: A record provides value semantics and with support; only a positional record synthesizes Deconstruct automatically.
records and aggregates: practical reference: Aggregates group components into one value; tuples and positional records support deconstruction, while a non-positional record does not synthesize Deconstruct automatically.
recursion: practical reference: Recursion solves a problem by calling itself on a smaller case and defining a terminating base case.
reductions and statistics: practical reference: A reduction folds a sequence into a statistic such as sum, mean, minimum, or histogram.
reflection and expressions: practical reference: Reflection reads metadata and operates dynamically on types and members.
Resource disposal is controlled cleanup when a resource is no longer needed. Synchronous `using` can call `IDisposable.Dispose` or a `Dispose` method that matches the disposal pattern on a `ref struct`, even if the type does not implement `IDisposable`. For asynchronous cleanup through `IAsyncDisposable.DisposeAsync`, use `await using`. Both constructs arrange cleanup when control leaves the scope, including because of an exception. Disposal is distinct from garbage collection reclaiming memory.
scope and lifetime: practical reference: Scope determines name visibility, while lifetime determines how long a value or resource is valid.
security boundaries: practical reference: Security requires boundary validation, least privilege, and context-sensitive data encoding.
sorting and comparison: practical reference: Sorting orders elements according to a consistent comparer and chosen stability.
Span<T> and Memory<T> describe regions of existing buffers without copying their elements. Learn their lifetime restrictions, read-only variants, and text processing with AsSpan, IndexOf, SequenceEqual, and TryParse.
strings and text: practical reference: .NET strings are immutable sequences of UTF-16 code units.
testing and assertions: practical reference: A test verifies an observable contract in a controlled arrange-act-assert setup.
dates and time: practical reference: Time includes an instant, local date, zone, offset, and duration as distinct concepts.
Conversions let you use an expression as a value of another type. Learn about implicit conversions, explicit casts, boxing, and unboxing. The C# specification requires an exact type match when unboxing to a non-nullable value type, but the .NET runtime also lets you unbox an enum as its underlying integral type. Under the specification, a nullable target accepts `null` or a boxed value of its underlying type.
type system: practical reference: The type system defines values, conversions, generic constraints, nullability, and dispatch.
variables: practical reference: A variable has a type and scope, requires definite assignment, and stores a value or reference.
Console.WriteLine: practical reference: Console.WriteLine writes a formatted representation to the current standard output and appends TextWriter.NewLine.
Square brackets access a list by position and a dictionary by key. An invalid list index and a missing dictionary key raise different exceptions.
Use the static `Array.IndexOf` method to find the first occurrence of a status in an array and check whether that status is allowed.
Set a channel's buffer limit and see why, when it fills up, `TryWrite` returns `false` immediately but `WriteAsync` waits asynchronously for room.
Learn when C# copies a value into an object, why the boxed type must match when unboxing, and which exception each kind of failure produces.