Creating an Array3:27 with James Churchill
In this video, we'll introduce our first challenge—creating an array for our Media Library program media type items.
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.
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
Comment out any code past the calls to the
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
You need to sign up for Treehouse in order to download course files.Sign up