Sponsored Ad

Saturday, May 5, 2012

Initialize Char Array and Print in C#

The below program will help you to initialize the char array. While defining the array you can pass the set of value to directly initialize it. The for loop is used here to print the char array values.

Initialize Char Array and Print in C#

using System;

namespace ConsoleHub
{
    class Programs
    {
        static void Main(string[] args)
        {
            char[] CharArray = { 'A', 'B', 'C', 'D', 'E' };

            for (int i = 0; i < CharArray.Length; i++)
                Console.Write(" {0}", CharArray[i]);         

            Console.ReadLine();
        }
    }
}

No comments:

Post a Comment

Sponsored Ad

Development Updates