.NET 010: What's new in C# 8.0 with Jason Bock
In this week’s episode of Adventures in .NET the panel is joined by Wai Liu, the new panelist, and Jason Bock, the special guest. Wai shares a bit about himself, currently, he works as a PM from Australia. His focus lately has been on Azure and .NET Core. Jason Bock introduces himself next, he is a practice lead for application development in .NET. He is a writer and a speaker, often about the new features of C#.
The panel interviews Jason about the new features found in C# 8.0. The first thing developers should know about C# 8.0 is that it is no longer tied to .NET Framework. Jason explains that everything is slowly shifting to .NET Core and developers can only enjoy all the C# 8.0 features with .NET Core 3. He lists that some of the features can be used with .NET Framework.
The panel discusses migration to .NET Core from .NET Framework. Jason explains that it is not a question of if we should migrate but when should we migrate. Not only does .NET Core have better capabilities and speed but Microsoft is focussing all their future efforts in .NET core. Jason invites everyone to think about switching over and start making a plan.
The panel considers how hard it will be to move over large applications into .NET Core. Jason explains that since Microsoft has many applications in .NET framework they are in the same boat as other large enterprises. So, support for .NET Framework 4.8 will continue to be supported. The panel considers their current projects and how migrating could affect them.
Moving on to the new features of C# 8.0, the panel considers the two most exciting new features, default interface members and nullable reference types. They start by discussing nullable reference types. Nullable reference types allow developers to annotate types in parameters and properties and say that they are nullable.
The panel discusses the opt-in function of this feature and why that is necessary at this stage of its release. Jason explains how this all works and the two main purposes for nullable reference types. First, it is trying to reduce the number of null references developers get. Second, it allows developers to try expressing intent.
The panel shares their excitement to give nullable reference types a try. They also warn developers that they may want to run away when they first turn it on. Jason advises developers to turn it on in new projects, but for large projects, he advises developers to turn it on a profile basis. He explains that Microsoft is just getting started with nullable reference types and will continue to make changes all the way to .NET 5.0.
Moving on to discuss default interface members, Jason predicts that default interface members will see a lot of abuse. The panel expresses their discomfort with the feature as it is a new way of using an interface. Jason explains the intent of this feature is to provide a way for developers to define an interface where some of the members have implementations. It is commonly referred to as default interface methods as most examples are with methods. The goal of default interface members is to improve versioning with interfaces. Jason explains that there are many possibilities for this feature and goes over some of them with the panel.
Jason explains that the difference between an interface and an abstract class is, an abstract class can have constructors and state whereas an interface cannot. The panel considers how default interface members could be considered normal practice in the future. Jason explains that there is still a lot of uncertainty around when to use them and when not to, it will take some time for default interface members to find their place.
The other features discussed are the enhancements made to pattern matching, asynchronous streaming, enhancements of the using, ranges and indices. They explain briefly what each of these features does and how they will improve the .NET experience.
- Shawn Clabough
- Caleb Wells
- Wai Liu
- Jason Bock
- Eliminating Nulls in C#
- What's new in C# 8.0
- What's new in C# 8 - Part 1
- What's new in C# 8 - Part 2
What is the first thing developers should know about C# 8.0?
C# 8.0 is no longer tied to .NET Framework
What are nullable reference types?
They allow developers to annotate types in parameters and properties and say that they are nullable.
What is Jason Bock's advise for opting-in to nullable reference types.
Jason advises developers to turn it on in new projects, but for large projects, he advises developers to turn it on a profile basis.
What is the difference between an interface and an abstract class?
An abstract class can have constructors and state whereas an interface cannot.