From the course: C# Essential Training 1: Types and Control Flow

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Working with nullable reference types

Working with nullable reference types - C# Tutorial

From the course: C# Essential Training 1: Types and Control Flow

Working with nullable reference types

- [Instructor] As we work with these nullable reference types, let's start here at the top of the file and work our way down applying the different features that comprise that nullable reference type. So I'm getting a warning here because, string in this context now that I've made that project level change, isn't nullable. It's like an int or a date time of value type, but it still behaves as a reference type. I can use that same syntax, putting a question mark at the end just like I did for the value types, to indicate that this is a nullable reference type. So again, it's all about providing that compiler help. We see that now it's okay to assign null there. If we go down to the next place for our string that we're having a problem is line 16 where that input could be null. One of the things we can do is go to our method now and apply an attribute that says allow null, that's not in scope in the namespace here but if I hit control + period there, using system diagnostics code…

Contents