Use Generic Collections to work with items in a strongly typed fashion.
Better than arrays:
Know the type of the item for a certainty, no casting / converting
Better performance inserting / removing / updating
Collections provide more flexible actions to access items in the collection.
Allows for LINQ extension methods
Many different type of collections – specialities
“Generic Collections”
List
Dictionary <TKey, TValue>
T => Data type you need
“You make a generic specific by providing a data type”
List – only store strings (strong typed)
List – only store Cars in that collection
//Assume I have three objects: car1, car2, car3 List cars = new List(); cars.Add(car1); cars.Add(car2); cars.Add(car3); int numberOfCars = cars.Count; Car myCar = cars.ElementAt(1); // returns second car in the element.
// Terminology: You access a member of a collection.
// LINQ Queries