Tuple-returning Func delegates, accumulators, and size validation
Use one delegate to report conversion success and another to update an accumulator. Throw an exception when the requested size is outside the allowed range.
CKTIS / Knowledge base
Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.
Use one delegate to report conversion success and another to update an accumulator. Throw an exception when the requested size is outside the allowed range.
Pass separate success and error delegates to `Match` with a shared return type. Use `FormattableString.Invariant` to format interpolation without relying on the current culture.
Distinguish three formatting contracts: looking up a service, intercepting a format item, and letting the value's own type produce the text.
Define the `Price.ToString` contract, pass numeric settings through to `decimal`, and change the decimal separator on a writable copy rather than on the original.
Create a view of text without copying it, search for an element or sequence, and print the matching slice through `Console.Out.Write` without creating a substring.
Use spans to search and compare existing text without copying it, then parse fields as `int` or `decimal` with explicit format rules.
Choose an explicit tie rule: round to the nearest value, but at an exact midpoint choose the result with the larger absolute value.
IEnumerable provides an enumerator, and IEnumerator tracks the position in a sequence. An explicit implementation satisfies the non-generic contract without duplicating iteration logic.
Enable nullable analysis and describe both outputs of a `Try*` method so the compiler knows that neither output is null on success.
Enable nullable reference annotations and compiler warnings. See how a null check affects flow analysis and why `string?` does not work the same way as `int?`.
Store behavior in variables and pass it as arguments: Action performs an operation, Func returns a result, and Predicate tests a condition.
Use `Array.Clone()` to create a separate array, then sort it in place with `Array.Sort` and a `Comparison<T>` delegate. The clone can still share element objects with the original.
Declare where an attribute is valid, select public instance properties, and distinguish attributes applied directly from those found through inheritance.
Choose the delegate for an event with or without data, and learn how to remove a handler when it is no longer needed.
Bind an argument to a delegate with partial application, see what a closure captures, and keep decimal rounding separate from culture-invariant formatting.
Use one delegate to calculate a decimal amount from a product and another to turn that amount into text with an explicit format.
Use `Func<T>` as a parameterless factory and `Action<T>` to reset a returned object in your own pool.
Read the ISO 4217 currency code for an explicit region and distinguish it from the region code and the symbol displayed next to an amount.
`System.IDisposable` is the synchronous cleanup contract. Use `using` to choose when cleanup runs, and make it clear who is responsible for it.
Resolve positions from either end of a sequence, validate slice boundaries, and tell when slicing copies elements or returns a view.
Use `INumber<T>` to write one algorithm for multiple numeric types, get the target type’s zero, and convert values with range checking.
Combine lookup flags to select methods by visibility, by whether they are instance or static, and by where they are declared.
Start a real thread, use a monitor to wait for shared state to change, and wait separately for the thread to finish. A notification does not prove that the condition is true.
Build a System.Text.Json converter that reads and writes one JSON object, rejects invalid tokens, and explicitly applies camel-case naming and null omission.