Learn how to create a list in C#, then add elements, remove elements, count elements, and clear all elements. Explore the standard mistake of forgetting to instantiate the empty list in the constructor.
- [Instructor] In the last video,…we finished our inventory system…but we don't have a way, right now,…to actually display the inventory itself…and therefore we can't really check…to make sure that it's working correctly.…So let's make a change to the two string method down here.…We can add our inventory output here.…So I'm going to go down to the bottom of the two string method…and I'm going to add a line here.…I'm going to say characterString.AppendLine.…
And I'm just going to put a bunch of dashes in…and then I'll put in inventory and a bunch more dashes.…Just to give it a little bit of a separator.…The next step is to loop through all of the things…that are in inventory right now.…And there's a special kind of loop…that's designed to work with lists and other collections.…And that's the for each loop.…It looks like a normal for loop,…it just has slightly different syntax.…Let's take a look at it, I'll type in for each,…var item in inventory.…
So what I'm doing here…is I'm creating a variable called item.…Normally in a for loop I would have to track…
AuthorBruce Van Horn
- Exploring C# on a Mac
- Creating a reusable code library
- Classes and properties
- Loops, arrays, and lists
- Creating a console app
- Creating a command-line app
- Creating a Mac desktop app
- Creating a UI with view controllers and actions
Skill Level Beginner
New Features Xamarin and Visual Studio 2017with Kevin Ford1h 44m Intermediate
Docker for .NET Developers with Visual Studiowith Lee Brandt46m 52s Intermediate
1. C# on the Mac?
2. Getting Started with C#
3. Deeper into C#
4. Creating a Mac App
Next steps3m 14s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.