Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Insider News
  4. Pattern matching in C# 8.0

Pattern matching in C# 8.0

Scheduled Pinned Locked Moved The Insider News
csharpcomregexcode-review
8 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kent Sharkey
    wrote on last edited by
    #1

    MSDN Magazine[^]:

    Pattern matching was introduced in C# 7.0 and changed the way we look at identifying the patterns and traits of our types. The changes in C# 8.0 make this even more intuitive and improve both flexibility and readability.

    "Methinks it is like a weasel"

    D F realJSOPR J B 5 Replies Last reply
    0
    • K Kent Sharkey

      MSDN Magazine[^]:

      Pattern matching was introduced in C# 7.0 and changed the way we look at identifying the patterns and traits of our types. The changes in C# 8.0 make this even more intuitive and improve both flexibility and readability.

      "Methinks it is like a weasel"

      D Offline
      D Offline
      Dominic Burford
      wrote on last edited by
      #2

      This looks like a really useful language feature :)

      "There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult." - C.A.R. Hoare Home | LinkedIn | Google+ | Twitter

      1 Reply Last reply
      0
      • K Kent Sharkey

        MSDN Magazine[^]:

        Pattern matching was introduced in C# 7.0 and changed the way we look at identifying the patterns and traits of our types. The changes in C# 8.0 make this even more intuitive and improve both flexibility and readability.

        "Methinks it is like a weasel"

        F Offline
        F Offline
        Forogar
        wrote on last edited by
        #3

        This looks like a feature that is completely not needed and is just there to justify the jobs of people to make new features. There is nothing inherently wrong with this feature, it's just that it doesn't bring any new functionality to the language, just syntactic sugar basically.

        - I would love to change the world, but they won’t give me the source code.

        F 1 Reply Last reply
        0
        • K Kent Sharkey

          MSDN Magazine[^]:

          Pattern matching was introduced in C# 7.0 and changed the way we look at identifying the patterns and traits of our types. The changes in C# 8.0 make this even more intuitive and improve both flexibility and readability.

          "Methinks it is like a weasel"

          realJSOPR Offline
          realJSOPR Offline
          realJSOP
          wrote on last edited by
          #4

          They're trying to make c# typeless, like other bastard languages, such as VB, and javascript... I don't like it at all.

          ".45 ACP - because shooting twice is just silly" - JSOP, 2010
          -----
          You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
          -----
          When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

          F 1 Reply Last reply
          0
          • realJSOPR realJSOP

            They're trying to make c# typeless, like other bastard languages, such as VB, and javascript... I don't like it at all.

            ".45 ACP - because shooting twice is just silly" - JSOP, 2010
            -----
            You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
            -----
            When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

            F Offline
            F Offline
            FIorian Schneidereit
            wrote on last edited by
            #5

            #realJSOP wrote:

            They're trying to make c# typeless, like other bastard languages, such as VB, and javascript... I don't like it at all.

            I've got mixed feelings about this. Both the strong-typed and typeless concepts have their pros and cons. It's more frustrating that you cannot combine the best of both worlds into a single approach.

            1 Reply Last reply
            0
            • F Forogar

              This looks like a feature that is completely not needed and is just there to justify the jobs of people to make new features. There is nothing inherently wrong with this feature, it's just that it doesn't bring any new functionality to the language, just syntactic sugar basically.

              - I would love to change the world, but they won’t give me the source code.

              F Offline
              F Offline
              FIorian Schneidereit
              wrote on last edited by
              #6

              Well, it doesn't bring new functionality but it makes some things easier to write and lets you express something that wasn't possbile before but felt it should have been there from day one. Like, for example, I always wondered why I cannot use the switch statement for type matching. Now I can, and it's a good thing. And there is some new functionality, like default interface implementations. The thing is: Introducing new features will likely require a change to the underlying runtime itself, and I like that C# was pretty conservative about that in the past until today. But, agreed, some of the syntactic sugar is already overloading the language, but at least you are not forced to use it. C++ is a really ugly language, now that C# is almost 20 years old and still readable and quite clean speaks for their designers.

              1 Reply Last reply
              0
              • K Kent Sharkey

                MSDN Magazine[^]:

                Pattern matching was introduced in C# 7.0 and changed the way we look at identifying the patterns and traits of our types. The changes in C# 8.0 make this even more intuitive and improve both flexibility and readability.

                "Methinks it is like a weasel"

                J Offline
                J Offline
                Joe Woodbury
                wrote on last edited by
                #7

                I "love" articles which assert that the new version/language "reads better" when it's blindingly obvious that it doesn't.

                1 Reply Last reply
                0
                • K Kent Sharkey

                  MSDN Magazine[^]:

                  Pattern matching was introduced in C# 7.0 and changed the way we look at identifying the patterns and traits of our types. The changes in C# 8.0 make this even more intuitive and improve both flexibility and readability.

                  "Methinks it is like a weasel"

                  B Offline
                  B Offline
                  Bernhard Hiller
                  wrote on last edited by
                  #8

                  Yeah, we know: it's hardly ever a code smell when you try to find out the concrete type of a variable instead of working with its generic type information (interface, base class). :~

                  Oh sanctissimi Wilhelmus, Theodorus, et Fredericus!

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups