What's new in C# 7.0 with Mads Torgersen

Download this episode

Download Video

Download captions

Download Captions

Description

In this video I invited the illustrious Mads Torgersen to my office to help me out with some code! Our goal was to see how C# 7.0 could be used to improve some existing code. In this video we explored Tuples, Pattern Matching, Local Functions, Out Parameters, and more! I figured that instead of talking about them we would dive into my machine learning library to update some of the older constructs in favor of some of the new syntax. Enjoy!

Tag:

C#

Embed

Format

Available formats for this video:

Actual format may change based on video formats available and browser capability.

    The Discussion

    • User profile image
      pvenky

      At ~15 mins, the second bool check that was deleted - that was a bug. Should've been checking if it was double since you were typecasting to a double in the return line.

    • User profile image
      Vitoc

      Outstanding session, gentlemen. Nice to see real-world examples in production code rather than working with contrived throwaway projects with the simplest use cases. The cameo by Mr. Hanselman was a nice surprise as well. ;)

    • User profile image
      Sanjeev

      Great Session with live example and live code changes with C# 7.0 features. Should do more of this type of live code changes show.

      Thank you again.

    • User profile image
      kreativmasc​hine

      ...was fun. more of this, plz!!!

    • User profile image
      syyad

      great live code refactoring using c# 7. thanks both you guys for this fantastic session

      however Scott didn't hang on till the end, thanks to him as well.

    • User profile image
      Niner566548

      Really good stuff. Much appreciated you guys.

    • User profile image
      doug

      That was a really great discussion of these three new useful C# features. I was particularly impressed with the interactive code update approach. It locks in the concepts as one can see the thinking real time. The discussion of the var out in the third example went off in the wrong direction briefly until it became clear the issue wasn't scope but the possible return of an unassigned variable. This was great to follow along as it really helps lock in exactly what is going on and helps us use this cool shorthand. More of this!

    • User profile image
      captainnemo

      Please re-enable forward/rewind buttons. Thanks.

    • User profile image
      Aluan
      Great video. Great interactive refactoring session. I love stuff like this, keep it up!
       
      At 27:37 the nastiness of out var is pretty undeniable. Maybe I will come to accept it but it seems to me the antithesis of declarative programming to have a name extracted from a nested short-circuiting conditional into a parent scope and rebound. It is just not clear at all where it comes from and even when you see it, it would be better declared beforehand because it makes the second use clearer.
       
      I think out var is the first truly bad feature ever added to C#.
       
      All of the changes in this session (case b when b was just illustrative, predicated cases are great) improved the code making it better written as C# 7.0, even where it was suboptimal C# 6.0, except for that one.

    Add Your 2 Cents