The System.Collections Namespace3:24 with Jeremy McLain
The System.Collections namespace contains many other collections. Some of them are no longer used though.
Create a console application to keep track of things in your to-do list. Allow finding items in the list that are due on a given date or finished on a given date. Each item in the list should have the following fields:
- Due Date
- Date Finished
Create a console based version of the Memory board game. You can find the rules here. Use words for the cards. To make it slightly more complicated, you can allow the player to pick the grid size. Clear the screen between turns using Console.Clear().
Create a console application to keep track of contact information. Print the contacts of the address book in sorted order first by last name, then by first. For each person in the address book have fields for:
- First Name
- Last Name
- Phone Number
- Email Address
So far, we've only been working with collections in 0:00 the System.Collections.Generic namespace. 0:03 There are a couple of other namespaces that contain collection types that 0:06 you should be aware of. 0:09 These can all be found in the ParentSystem.Collections namespace. 0:10 I've included a link to a page that lists them in the teacher's notes. 0:14 The System.Collections.Object model namespace contains a number of 0:18 collections that are designed to be the base classes of other collection types. 0:22 When creating our own collection types, 0:27 it's often a good idea to start with one of these. 0:30 These are also generic classes that can work with any type of object. 0:33 Collections found in the System.Collections.Concurrent namespace 0:37 are used to share data between threads. 0:41 Computers can run code concurrently or 0:44 simultaneously with other code in a program. 0:47 This code is said to be running in separate threads. 0:50 The most difficult aspect of threaded programming is making sure that one thread 0:54 isn't unexpectedly changing the data that another thread is working with. 0:58 Concurrent programming is a topic for another day, but the collection types 1:03 provided here make threaded programming much easier and safer. 1:07 There are a number of collection types that are provided by 1:11 the System.Collections namespace itself. 1:14 They're listed here. 1:16 These are the original collection types provided by .Net before C# 1:18 had the capability of generic classes. 1:23 These non-generic collection types work with the base, 1:25 System.Object type that all other types inherit from. 1:28 This means, they can store any type of object. 1:32 However, we'd have to cast the object back to its actual type before we could use it. 1:34 This can be quite cumbersome. 1:40 Almost all of these collection types now have equivalents 1:42 in the System.Collections.Generic namespace. 1:45 The generic versions of these collections are easier to use and 1:48 are also more efficient. 1:52 These collections are now considered deprecated by most developers meaning, 1:54 they aren't used anymore. 1:58 They're still here for historical purposes though. 2:00 It's the same story with the collections 2:03 found in the System.Collections.Specialized namespace. 2:05 As the name suggests, these collections are more specialized and 2:08 less commonly used. 2:12 However, there are types of collections in here that don't have generic equivalents. 2:13 There are also a number of collection types in here that only work with strings, 2:18 but they're rarely used. 2:22 In general, it's always best to use a generic collection type. 2:24 Whoo, that about does it for collections provided by .NET. 2:28 There are many other useful collections that don't have implementations in .NET. 2:32 See the teachers notes for a list of some of these. 2:37 You may find that you wanna use a collection that isn't provided by 2:41 the .NET Framework. 2:44 In that case, you may be able to find third party libraries 2:45 that provide implementations of them. 2:49 Or you may want to implement your own collection type, 2:51 .NET makes it easy to extend existing types of collections or 2:54 combine them in unique and fascinating ways. 2:58 Using the right collection type for 3:01 what you want to do can greatly simplify your code and make it more efficient. 3:03 The more collections you know about, 3:07 the more likely you are to pick the right one for the job and use it correctly. 3:09 If you'd like to practice using some of the collections we've discussed here, 3:13 I've included a few project suggestions for you to implement on your own. 3:17 Until next time, happy coding. 3:21
You need to sign up for Treehouse in order to download course files.Sign up