Part 7 - Collections
A collection is a structure that holds a number of the same types of values in a specific order. They provide functionality to easily access, search, sort and modify these values. Values can be added and removed as needed while your program is running. This section will cover how to use arrays and lists as collections of data.
Lists and Arrays
What do Do?
1 - Read through and complete the exercises in Part 7 - Arrays
Exercise solutions can be found here:
While arrays are not as commonly used as lists because they lack functionality, they are the underlying structure behind lists and have faster performance than lists.
Here is the official C# documentation:
Nothing to hand in for this part!
2 - Read through and complete the exercises in Part 7 - Lists. You should be able to do the following by the end of this section:
Create a new list of any type:
An empty list.
Created with values at initialization time.
Add items to a list.
By appending the list (adds to the end).
By inserting to any position in the List (adds an element at a specified index).
Remove items from the list by index or by value (will remove the first occurrence with the specified value).
Modify values in the List by index.
Iterate through the List using a loop (counted for loop and for each loop).
Sort the list.
Here is the official C# documentation for a List:
https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1?view=netframework-4.8
Have a look at the Methods section to see if there is anything that looks helpful.
3 - Complete the Lists PRogramming Assignment specified in Part 7 - List.
SUBMIT
1 - The Lists Programming Assignment specified in Part 7 - Lists.
Use the Menu loop to allow for testing of multiple functions.
If there is anything you cannot do, just don't implement it but leave the menu options there.
Hints/FAQ
Q: What is the difference between a list and an array?
A: https://csharp-station.com/c-arrays-vs-lists/
Q: I want to use RemoveAll() instead of using a loop. How do I do it?
A: https://stackoverflow.com/questions/29895657/c-sharp-remove-an-int-from-a-listint