August 2010
Intermediate to advanced
1224 pages
34h 17m
English
You can now define a collection class or an array and, at the same time, set the initial values in your object. This turns multiple lines of code calling simple add methods into a single line. This is especially useful if you have a list of items that your application works with and you need to both declare the list and initialize these values.
As an example, you might need to define an array to contain the geographic locations for your sales office. You could define this array and initialize it as follows:
C#
string[] salesGeos = {"South", "Mid Atlantic", "Mid West"};
VB
Dim salesGeos() As String = {"South", "Mid Atlantic", "Mid West"}
You can use similar syntax to define and initialize a collection ...