reductions and statistics: practical reference
reductions and statistics: practical reference: A reduction folds a sequence into a statistic such as sum, mean, minimum, or histogram.
CKTIS / Knowledge base
Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.
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.
Look up a dictionary value with a fallback and know when to distinguish a missing key from a stored `null`.
`Environment.Exit(0)` ends the current process with a success status. Assigning to `Environment.ExitCode` only sets the status and lets the program continue.
End the entire process after printing a report and signal success with exit code `0`. Learn when returning from `Main` is the better choice.
Use `Func<bool>` to test signal classification rules and `Action<int>` to notify the caller after processing a unit.
Register factories with different service return types in a custom container, then use the same delegate type to filter and transform a sequence with LINQ.
Use a bool-returning delegate to filter items, a decimal-returning delegate to select amounts, and invariant formatting to render the total.