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 - Visual Basic Tutorial
From the course: Visual Basic Essential Training
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
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
(Locked)
Explore the collection classes10m 18s
-
(Locked)
Use a ListBox instead of a text control3m 10s
-
(Locked)
Create new collections6m 30s
-
(Locked)
Initialize a collection2m 23s
-
(Locked)
Add items to a list1m 13s
-
(Locked)
Get items from the list3m 16s
-
(Locked)
Remove items from a list1m 15s
-
(Locked)
Iterate over a list5m 20s
-
(Locked)
Bind a list to a user control5m 46s
-
(Locked)
Delegates and lambda expressions4m 36s
-
(Locked)
Customize a method with predicate functions5m 21s
-
(Locked)
Quick look at other collection classes4m 28s
-
(Locked)
-
-
-