Do more with patterns in C# 8.0

#244 – February 03, 2019

sponsor

Find A Job Through Vettery

Vettery specializes in tech roles and is completely free for job seekers. How does it work? You apply to join the platform, and once accepted, you’ll start receiving interview requests directly from top companies growing their tech teams. You decide which interviews you want to take, all from the comfort of your inbox!

this week's favorite

Do more with patterns in C# 8.0

When C# 7.0 introduced pattern matching we said that we expected to add more patterns in more places iin the future. That time has come! We’re adding what we call recursive patterns, as well as a more compact expression form of switch statements called (you guessed it!) switch expressions.

C# Deadlocks in Depth – Part 2

Continuing with C# Deadlocks in-depth adventure. Examining 2 more deadlock types: The UI Dispatcher Queue deadlock and Sync-Context deadlock. Also, debugging deadlocks with the Tasks Window in Visual Studio.

Creative use of extension methods

I'm sure everyone with at least some background in C# is aware of extension methods – a nice feature that lets developers extend existing classes with new methods. This is extremely convenient in cases where you want to add functionality to types you don't have control over – I think everyone at some point authored extensions for the base class library just to make some things more accessible.

yield return await and await foreach geekery

This is just a pure geekery, but as I was playing with asynchronous enumerables I realized I can combine the await and yield return together. In fact, I can even throw await foreach into the mix.

C# 8 using declarations

The one I like a lot is using declarations. This allows a local to automatically be disposed at the end of the block. Essentially, it hides the try/finally or the using() {...}. The .NET team’s blog kind of gave a bad example of this, so I’ll use one from Open OPC SignTool.

newsletters