Exercise: NullReferenceException and Collections

Play around with arrays and lists to get a NullReferenceException.

We'll cover the following

So far, we’ve learned that we get a NullReferenceException when we call a method or property on an uninitialized object reference, either by returning null from a method or by passing it as a parameter. But we can also find this exception when working with collections, such as arrays and lists.

Now, let’s play with arrays and lists to get a NullReferenceException.

Get hands-on with 1200+ tech skills courses.