Coding Shorts: Don't Be Afraid of Pattern Matching in C#

preview_player
Показать описание
Pattern Matching has been with us for several iterations of C# already, but how many people are daunted by it. I was. Let's demystify it a little:

00:00 - Introduction
00:40 - Your First Pattern
03:27 - Pattern Match to a Variable
04:23 - Pattern Matching Switch Statements
07:07 - Enums
08:43 - Numbers
09:04 - Ranges
10:54 - Multiple Values
11:55 - Objects
14:09 - Arrays
15:28 - Wrapping Up

If you like this video, you might like other videos in my Instructional Videos:

You can reach me at my new website:
Рекомендации по теме
Комментарии
Автор

This is very helpful, Shawn. Your concise format is great. And I can't tell you how much I appreciate you saying, "let's get started..." and then not making me watch a 90 splash screen. Thank you!

rogerpence
Автор

I glossed over pattern matching as I didn't really see a need for it. Thought it was more gimmicky than useful. Now, I must retract my original opinion. I really am glad that you take the time to make these coding shorts. The usefulness I have found in them is almost better than a Pluralsight/Udemy subscription. These are actually applicable to the work I do every day.

Thank you!

godfathermikal
Автор

Thank you Shawn. Pattern matching is a really powerful tool. The only problem for me personally is that now I use it by default whenever I can, but I need to remember which features are supported by each C# version 😁.

seriyezh
Автор

Fully agree with the concise format. Very good and thanks again!

arjanvandenberg
Автор

Took me about 15 minutes in to the video to see the Falcon, have my build of that same same model on a shelf behind me in view when doing conference calls. Mind blown by the pattern matching, I'm guessing this is a "Core" feature? My current project dreams of going to Core but there's currently no real reason to move but we have considered doing some reasonably free standing part in Core just to get started.

rumbust
Автор

Great video Shawn... Im a big fan of your teaching style. Easy to follow and understand. Thanks

vssang
Автор

I've managed to miss pattern matching feature somehow but it's ultra powerful. It gives you so much power of method logic customization (e.g. where your logic should be different for enumerable regarding their sizes).

Great explanation - hope I'll make use of this sooner than later :)

mazingguitar
Автор

I've just subscribed on the basis of this video. I'm still trying to figure out when the pattern-matching switch counts as an improvement to the code. I'm clear that the answer is "Not always". Conciseness isn't always a virtue, especially if you end up with write-only code that the reader has to unpick.

DominicCronin
Автор

Hi, Wouldn't using 'when msg is string' be redundant since it will already be matched as a string using 'string s'

clearz
Автор

Afraid? I get annoyed when i can't use it as fully as i want to!

RiversJ
join shbcf.ru