October 2010
Intermediate to advanced
1920 pages
73h 55m
English
Generics are not a new feature; however, they are such an important aspect of LINQ to SQL that it is worth using a little space to review this feature.
To use generics, you need to import the System.Collections.Generic namespace.
I most often use generics by taking advantage of generic collections. For example, if you want to represent a list of strings, you can declare a list of strings like this (in C#):
List<string> stuffToBuy = new List<string>();stuffToBuy.Add("socks");stuffToBuy.Add("beer");stuffToBuy.Add("cigars");
Here’s how you would declare the list of strings in VB.NET:
Dim stuffToBuy As New List(Of String)stuffToBuy.Add("socks")stuffToBuy.Add("beer")stuffToBuy.Add("cigars")
And, by taking advantage of ...
Read now
Unlock full access