Category: C#

Generalized Async Return Types in C# 7.0

Instantiating a Task in C# 7.0 Ever since C# 5.0 when the async/await pattern was introduced, the only supported return types were Task, Task, and void (the latter only in exceptional cases). The problem with this limitation is that on occasions when the result is known immediately, it is still necessary to proceed with the formality […]

C# 7 Deconstructors: Implement an Implicit Conversion

Deconstructors in C# 7 While the deconstruct syntax is interesting for its convenience in assigning to a set of variables, what I believe has far broader implications is its potential to provide an “implicit conversion operator” and in a syntax that, quite frankly, is far easier to recall than the implicit cast operator.  For example, […]

Deterministic Finalization With IDisposable and the Using Statement

Understanding Deterministic Finalization The problem with finalizers on their own is that they don’t support deterministic finalization (the ability to know when a finalizer will run). Rather, finalizers serve the important role of being a backup mechanism for cleaning up resources if a developer using a class neglects to call the requisite cleanup code explicitly. […]