How to use foreach loop statement in c#?

Below code shows how to use foreach loop statement to iterate an array in c#/csharp –

using System;

namespace kodehelp.csharp.basic
{
    public class ForeachLoop
    {
        public static void Main(string[] args)
        {
            Console.WriteLine("Argument size: " + args.Length);

            foreach (string arg in args) {
                Console.WriteLine("Argument: " + arg);
            }
        }
    }
}

Please Post Your Comments & Reviews

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.