C# 7.0 introduced local functions and with C# 8.0 one can create static local functions. Let’s have a look at what differentiates them.
Some time ago I’ve created a library with a few simple but useful extensions. Note: LucidCode is an opinionated library, that helps me in my daily developer work. It doesn’t mean it will be perfect for everyone :) LucidCode contains a few useful methods, like In, NotIn, ToNullIfEmpty, etc. Here are some examples: The full list of methods can be found on the LucidCode source page. Support for Arrange Act Assert pattern – LucidTest Arrange Act Assert pattern (AAA) is a very powerful pattern for writing tests. The problem for me is that usually the AAA implementation is done by […]
Below you can find the list of all features introduced in C# 7. Tuples Deconstruction Out variables Patterns Discards Literal improvements Local functions Expression-bodied members Throw Expressions Ref returns and ref locals Generalized async return types
Before C# 7 every async method had to return Task, Task<T> or void. The new C# version extends the range of returned types.
Returning reference instead of value might be very useful – especially when one has to deal with big structures. C# allows passing parameters by reference, but a method was not able to return a reference. This has been changed with C# version 7.0.
Some time ago, I showed a way to avoid deadlocks when reading the redirected console of a child process in a synchronous way. It works, but only when we have to deal with a single output stream – standard output or standard error stream. But what should be done when both streams are flooded with data?
Before C# 7.0 it was not possible to throw an exception directly in expression-bodied members. The workaround was to call a method that throws an exception.
Expression bodied members were a very popular feature of C# 6.0. Unfortunately, their usage was limited only to methods and properties.
There are situations when one needs a small helper method, but it’s not quite obvious where to put it. The method might not be generic enough to expose it as a new entity or even as a class member.
C# 7.0 introduced nice improvements to literals. Both digit separator and binary literals can improve code readability.