O'Reilly logo

Introducing Visual C# 2010 by Adam Freeman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required