The method in which we access data from an array can be optimized by using a foreach
loop instead of either a while or for loop. Optimizing how we access data is important
due to the number of web applications that pull data from a database or an XML file and
must loop through each record to display data to the user. To demonstrate the
optimization, we will use the code shown in Listing 3–11.