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

แชร์
ฝัง
  • เผยแพร่เมื่อ 8 ม.ค. 2025

ความคิดเห็น • 28

  • @rogerpence
    @rogerpence 2 ปีที่แล้ว +6

    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!

    • @swildermuth
      @swildermuth  2 ปีที่แล้ว +1

      I appreciate that!

  • @seriyezh
    @seriyezh ปีที่แล้ว +1

    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 😁.

  • @godfathermikal
    @godfathermikal 2 ปีที่แล้ว +1

    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!

    • @swildermuth
      @swildermuth  2 ปีที่แล้ว

      Glad it was helpful!

  • @vssang4035
    @vssang4035 10 หลายเดือนก่อน

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

  • @arjanvandenberg5313
    @arjanvandenberg5313 ปีที่แล้ว

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

  • @Adminian357
    @Adminian357 2 ปีที่แล้ว +1

    Loving these Shawn!

    • @swildermuth
      @swildermuth  2 ปีที่แล้ว

      Thanks, fun doing them.

  • @rumbust7793
    @rumbust7793 2 ปีที่แล้ว +1

    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.

  • @shenmajid
    @shenmajid 2 ปีที่แล้ว +2

    Best explanation ever..

    • @swildermuth
      @swildermuth  2 ปีที่แล้ว +1

      Glad it was helpful!

  • @mazingguitar
    @mazingguitar ปีที่แล้ว

    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 :)

  • @a-s733
    @a-s733 2 ปีที่แล้ว +1

    Very clear. Thanks Shawn

  • @DominicCronin
    @DominicCronin 6 หลายเดือนก่อน

    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.

    • @swildermuth
      @swildermuth  6 หลายเดือนก่อน

      This difference here is being able to make more concise code that is easier to read and uses fewer allocations. But it's not a big enough difference to try and refactor all your existing code, but it's a nice arrow in the quiver.

    • @DominicCronin
      @DominicCronin 6 หลายเดือนก่อน +1

      @@swildermuth Oh - I agree, it's a nice arrow in the quiver, but I've already seen enough examples of people using switch expressions to write unbelievably dense code, and often to put far more logic in a function than makes sense. Conciseness can be beneficial, but use with care!!

  • @mattbristo6933
    @mattbristo6933 ปีที่แล้ว

    Brilliant video

  • @clearz3600
    @clearz3600 ปีที่แล้ว

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

    • @swildermuth
      @swildermuth  ปีที่แล้ว

      Yes, not my best example.

  • @antondoit
    @antondoit 7 หลายเดือนก่อน +1

    Great

  • @AbouLojyn
    @AbouLojyn 2 ปีที่แล้ว +1

    Awesome

  • @RiversJ
    @RiversJ ปีที่แล้ว

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