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 the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.