Sponsored Ad

Saturday, May 5, 2012

Char Array with foreach Loop in C#

This C# program is create a char array and then print the char array values using the foreach loop. The foreach loop start with first value of array and then iterate with all the values. The limitation of foreach that you can not update the array values.

Char Array with foreach Loop in C#

using System;

namespace ConsoleHub
{
    class Programs
    {
        static void Main(string[] args)
        {
            char[] CharArray = { 'm', 'n', 'o', 'p', 'q' };

            foreach (char ch in CharArray)
                Console.Write("->{0} ", ch);

            Console.ReadLine();
        }
    }
}

No comments:

Post a Comment

Sponsored Ad

Development Updates