Initialize char arrays : Char array : Data Type C# Examples


C# Examples » Data Type » Char array »

 

Initialize char arrays









    
using  System;

class  MainClass
{
    public  static  void  Main()
    {
        char[]  charArray  =  new  char[]  {'h',  'e',  'l',  'l',  'o'};
        for  (int  counter  =  0;  counter  <  charArray.Length;  counter++)
        {
            Console.WriteLine("charArray["  +  counter  +  "]  =  "  +
                charArray[counter]);
        }
    }
}
    
   
  
   



Output

charArray[0] = h
charArray[1] = e
charArray[2] = l
charArray[3] = l
charArray[4] = o


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Data Type
» Char array