From the course: Visual Basic Essential Training

Unlock this course with a free trial

Join today to access over 25,600 courses taught by industry experts.

Initialize a collection

Initialize a collection

- [Instructor] Look at line number nine, I'm declaring a new list of decimal, and I'm storing that in this variable empty. And as we go through the next couple of videos, we'll see how we can add items to this list and remove items from this list and get some of the items out of the list. But what I want to look at in this video is how we can initialize the list of T when we instantiate it. So this is what I'm doing here on line number 10. I'm declaring a list of decimal. And then in the set of parentheses after that, I have a set of curly braces that is a comma delimited list of decimal values. So after this line of code runs, there'll be four items in this sales list number one. I've been saying in this chapter that we should not be using arrays, it's better to use list of T, but let's be realistic, there are many parts of dot net or class libraries that you use, or there are work libraries you have that may return arrays. So we should be able to work with those. So that's why I…

Contents