Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
In this video, we'll review the solution to the second challenge and introduce our third and final challenge—updating our MediaLibrary `GetItemAt()` method to gracefully handle bad array indexes.
Instructions
3rd Challenge
-
In the MediaLibrary class, update the
GetItemAt()
method to gracefully handle a bad index.- Use the array's
Length
property to determine if an index is available before attempting to access it. - Return
null
if the provided index isn't available in the array of items.
- Use the array's
In the Program.cs file, update the
Display()
andDetectMediaType()
methods to handle a nullitem
parameter value.
Help
If you get stuck on any of the following topics or simply need a refresher, click on a topic in list below to view the associated video in the C# Objects course.
You need to sign up for Treehouse in order to download course files.
Sign up