How do I use foreach to iterate array?

Category: Introduction, viewed: 1226 time(s).

This examples displays how to use foreach statement to iterate array items.

using System;

namespace Kodecsharp.Example.Intro
{
    public class CommandLineForeach
    {
        public static void Main(string[] args)
        {
            Console.WriteLine("Argument size: " + args.Length);

            foreach (string arg in args) {
                Console.WriteLine("Argument: " + arg);
            }
        }
    }
}
Download Hundreds of Complimentary Industry Resources

Get hundreds of popular Industry magazines, white papers, webinars, podcasts, and more; all available at no cost to you. With more than 600 complimentary offers, you'll find plenty of titles to suit your professional interests and needs. Click Here and Sign up today!

Our Friends

Network Sites

Statistics

Locations of visitors to this page