To use list (of T), we need to know how to deploy. NET Framework provides a variety of methods. This is what this article will be about. I've written three examples--using foreach, FindAll, and sort--to illustrate how the same list class works.
The first step is to create a shared list. You can get data from a variety of sources, but the easiest way is to add it. Text, we'll write code to categorize the set in the example. So, let's talk about the code that creates the set.
First, I need an object that can represent the bottle of a set. The code written for this is perfectly compliant, and in fact, VB.net 2008 Express IntelliSense will write most of the code for you. The following are my objects:
Public Class Bottle
"internalProperties"
Public Property Brand() As String
Public Property Name() As String
Public Property Category() As String
Public Property Size() As Decimal
Public Sub New( _
End Sub
End Class
To create a set, I need to add a project:
Dim Cabinet As List(Of Bottle) = _
"New List(Of Bottle)
Cabinet.Add(New Bottle( _
"Castle Creek", _
"Uintah Blanc", _
"Wine", 750))
Cabinet.Add(New Bottle( _
"Zion Canyon Brewing Company", _
"Springdale Amber Ale", _
"Beer", 355))
Cabinet.Add(New Bottle( _
"Spanish Valley Vineyards", _
"Syrah", _
"Wine", 750))
Cabinet.Add(New Bottle( _
"Wasatch Beers", _
"Polygamy Porter", _
"Beer", 355))
Cabinet.Add(New Bottle( _
"Squatters Beer", _
"Provo Girl Pilsner", _
"Beer", 355))