Skip to main content

Posts

Showing posts with the label pattern matching

C# 8 is becoming too terse and it's going to backfire

I love working in C#, plain and simple. C# gets the job done, but - in it's latest preview, it's becoming too terse. Let me explain. A 'nifty logo don't you say? Patterns Have you ever heard of them? Well, besides software design patterns  or if you are hungry, cookie patterns , there is something called pattern matching in C# 7 and it is pretty handy. If you've never used pattern matching before, you can check if a variable is of a certain type and assign this variable to a new variable in a single line. The example below explains how this will work. Using the is type pattern expression Perhaps I haven't given it much thought to make use of this yet, but this feature out there and it makes sense. There really isn't any indication that we are assigning a variable in the code, we aren't using an equal sign or semi colon on the line, but still, it is an easy concept to learn. This new feature in C# 7 is not any more complicated than a ...