Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

How to: Iterate Through an Array

Visual Studio 2008

This example uses the foreach statement to access and display items of an array.

int[] numbers = {1, 2, 3, 4, 5, 6, 7, 8, 9};
foreach (int element in numbers)

Copy the code and paste it into the Main method of a console application.

Community Additions

© 2015 Microsoft