Exercise: Fixing Compilation Errors with Nullable References

Learn to enable and remove remove all nullable warnings.

Nullable references and arrays

With nullable references, we have type hints to tell when an object reference is not null or when it might be null. We can declare variables as either Movie movie or Movie? movie to make them non-nullable and nullable references, respectively.

There’s a known pitfall when turning on nullable references and using arrays. Sometimes, even though we’ve declared an array of a non-nullable type, it might be initialized to null without any compiler warnings.

For example:

Get hands-on with 1200+ tech skills courses.