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 introduce our first challenge—creating an array for our Media Library program media type items.
Prerequisites
This practice session assumes that you've completed stage 4 of the C# Objects course. If you haven't done that yet, go check it out, then come back to this workshop.
This practice session also builds upon the skills that are covered in these three practice sessions that cover stages 1-3 of the C# Objects course.
If you haven't completed these practice sessions yet, you might consider doing that first before attempting this practice session.
Instructions
1st Challenge
Declare a variable for an array of type MediaType.
-
Initialize the array with the existing media type subclass instances.
- Feel free to add additional media type subclass instances!
Update the calls to the
DetectMediaType()
method.Comment out any code past the calls to the
DetectMediaType()
method.
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.
- Recall that an array is a numbered list of items
- Recall that an item's position in an array is known as its "index"
- Recall that an array's first item has an index of "0"
- Recall that when declaring a variable for an array you start with the data type followed by a set of brackets ("[]")
- Declare a variable for an array of strings
- Instantiate an array of strings
- Set an array item's value
- Get an array item's value
- Set the items in an array when declaring it
- Declare and instantiate an array of strings using the concise syntax
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up