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

Unlock the full course today

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

Understanding nullable types

Understanding nullable types

- [Instructor] We've looked at various ways to define types. (indistinct) classes, structs and records. One of the things that many of them have in common, is that the variables can be null, meaning that they point to nothing. We look at this example, the string input is a variable, but it doesn't point to an actual string. The pointer in this case is null. If we have an int, it's a little bit different. With string for example, I could say if input does not equal null, and then I could write this out and I could say string is... I could even then put the string, so we can put here the input. And of course we put our placeholder in the string format there. But if I come down and try and do the same thing with the int, so I'll say if definiteInt, is not equal null, maybe I want to write out the value there of that. So I can just do, something like this and I can put the variable in there. And I'm getting some warnings here because, that definite int is a value type. Why does that…

Contents