Create char array - CSharp Language Basics

CSharp examples for Language Basics:Array

Description

Create char array

Demo Code

using System;/* w w w .j av  a 2  s .  c o  m*/
class Program
{
   static void Main(string[] args)
   {
      char[] charArray = new char[] { 'a', 'b', 'c' };
      Console.WriteLine("Character array size: {0}", charArray.Length);
      char[] secondArray = new char[4];
      Console.WriteLine("Second character array size: {0}", secondArray.Length);
      secondArray[0] = 'b';
      secondArray[1] = 'a';
      secondArray[2] = 'l';
      secondArray[3] = 'l';
      for (int i = 0; i < secondArray.Length; i++)
      {
         Console.WriteLine(secondArray[i]);
      }
      secondArray[2] = 'z';
      for (int i = 0; i < secondArray.Length; i++)
      {
         Console.WriteLine(secondArray[i]);
      }
   }
}

Result


Related Tutorials