Welcome4:04 with Jeremy McLain
Collections are used to organize data so that it can be used efficiently.
Hello and welcome to C# collections. 0:04 I'm Jeremy in this course will be learning 0:07 all about how to work with data in various types of collections. 0:10 Collections are used to organize data so that they can be used efficiently. 0:14 A more common term for a collection is a data structure and 0:18 you'll find that I use the terms interchangeably. 0:22 In C# we call them collections. 0:25 It's very difficult to write any sort of software program 0:28 without using a collection at least once. 0:31 In fact, if you've taken the prerequisites for 0:33 this course, then you're already familiar with arrays. 0:36 An array is a type of collection. 0:39 You may have also heard of lists, sets, and dictionaries. 0:42 These are the most common types of collections. 0:45 Although the title of this course is C# collections. 0:48 The collections we'll discuss here are all actually provided by the .NET framework, 0:51 which means they can be used by any .NET language. 0:57 We'll be using C# as we explore them. 1:00 There are dozens of different types of collections. 1:03 You might be wondering why there are so many different types. 1:06 They each have advantages and disadvantages. 1:09 Basically most collections support four fundamental operations, 1:13 Insert, Access and Find, Update, and Delete. 1:18 One way we can evaluate a collection is by how quickly it can perform 1:23 each of these operations. 1:27 So when we decide which one to use, we should consider when and 1:29 how often we need to perform these operations. 1:34 Because the job of a collection is to store data efficiently, we also 1:37 want to consider how much additional space it needs in order to store each item. 1:41 The amount of data the collection will store is also a factor. 1:46 Some are efficient for 1:50 small to medium amounts of data, and others are better for larger sets. 1:51 Additionally some collections can store items in the order we add them and 1:55 others, can't. 1:59 So if we want to maintain an ordered list of items, 2:00 we probably want to pick the collection that can do that for us. 2:04 Something else to consider is how quickly we can copy the items from one collection 2:08 into another. 2:12 This is actually very important because the way we store 2:14 data in our programs while we're working with it 2:17 is often different than the way that the data is displayed to a user. 2:19 As you can see, 2:24 there are many things to consider when picking which collection to use. 2:25 You may be thinking, this seems like a lot of hassle. 2:29 Isn't there a collection out there that we can use for everything? 2:32 The answer to that question depends on how much data you're working with. 2:36 If you're only storing a few items and the amount of data isn't going to grow, 2:40 then it doesn't really matter which collection you use. 2:44 Just pick the one that simplest to work with. 2:47 Picking the correct collection for 2:51 the job doesn't really become important until the amount of data you're working 2:52 with starts to affect the performance of the computer. 2:56 However, it's sometimes difficult to predict 2:59 how much data a program will have to deal with in the future. 3:02 A couple dozen items in a collection may not be a big deal. 3:05 Depending on how often it's being used but 3:09 it's not uncommon to be working with thousands of items or 3:12 even larger collections, especially in the age of big data sets that we live in now. 3:15 That's just one more thing to consider when picking a collection. 3:20 I found it important to know about many different types of collections, so 3:24 that I can pick the right one for the job. 3:28 In fact a very common question asked in job interviews 3:30 is which collection would you use to solve a given problem and why. 3:34 In this course we'll learn about four of the most common types of collections 3:38 arrays, lists, sets, and dictionaries. 3:43 Learning how these work can help you start to understand 3:47 how other types of collections work as well. 3:50 In the end of this course, we'll use what we've learned to create an application 3:53 that translates text into Morse code messages and back again. 3:57 To start, let's take a deeper look at arrays in C# 4:01
You need to sign up for Treehouse in order to download course files.Sign up