Chapter 13. Arrays

Arrays are special types that let you gather objects of the same type together conveniently and efficiently. Imagine you have a simple program that keeps track of a list of product names; Listing 13-1 gives an example.

Example 13-1. A Program with Multiple Instances of the Same Type

using System; class Listing_01 { static void Main(string[] args) { // define the product names string product1 = "oranges"; string product2 = "apples"; string product3 = "guava"; string product4 = "cherry"; string product5 = "strawberry"; // select the product names > six chars CheckLengthAndPrintName(product1); CheckLengthAndPrintName(product2); CheckLengthAndPrintName(product3); CheckLengthAndPrintName(product4); CheckLengthAndPrintName(product5); ...

Get Introducing Visual C# 2010 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.