Skip to Main Content
Professional ASP.NET 2.0 Special Edition
book

Professional ASP.NET 2.0 Special Edition

by Bill Evjen, Scott Hanselman, Devin Rader, Farhan Muhammad, S. Srinivasa Sivakumar
October 2006
Intermediate to advanced content levelIntermediate to advanced
1588 pages
37h 59m
English
Wrox
Content preview from Professional ASP.NET 2.0 Special Edition

Chapter 10. Collections and Lists

Object-oriented programming (OOP) has been successful because it gives programmers a way to model physical reality in code. The easiest systems to understand are those that effectively model a familiar reality. If you're trying to represent a person in real-life, for example, you might create a class Person. After you create a Person class, what's the next most obvious thing for that person to do? Well, have a party and congregate with other persons, of course! As soon as you have more than one Person, you need a place to put them all—that's where lists, arrays, hash tables, and other collections come in.

This chapter explains the collections made available to you in the .NET Framework 2.0. Although the concept of collections is not specific to ASP.NET, this chapter shows you how to use them in the context of an ASP.NET 2.0 application. It also looks at the differences between strongly typed collections and generics, as well as exploring the unusual Microsoft.VisualBasic.Collection class and contrasting it with the System.Collections namespace.

Arrays

Most folks would say that the simplest collection of objects is an array. Create some objects and put them into an array. Start with a basic Person class with a simple constructor that initializes the Person's first and surname (last name), as well as a public property that returns the full name (see Listing 10-1).

Example 10.1. A simple Person class

VB Public Class Person Dim FirstName As String Dim LastName ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Pro C# 2008 and the .NET 3.5 Platform, Fourth Edition

Pro C# 2008 and the .NET 3.5 Platform, Fourth Edition

Andrew Troelsen
ASP.NET 3.5 Unleashed

ASP.NET 3.5 Unleashed

Stephen Walther
Beginning Visual C#® 2005

Beginning Visual C#® 2005

Karli Watson, Christian Nagel, Jacob Hammer Pedersen, Jon D. Reid, Morgan Skinner, Eric White

Publisher Resources

ISBN: 9780470041789Purchase book