illustrates how to initialize arrays : Array : Collections Data Structure C# Source Code


Custom Search

C# Source Code » Collections Data Structure » Array »

 

illustrates how to initialize arrays









    


/*
  Example10_3.cs illustrates how to initialize arrays
*/

using System;

public class Example10_3 {

  public static void Main() {

    // int arrays
    int[] intArray = new int[5] {10, 20, 30, 40, 50};
    for (int counter = 0; counter < intArray.Length; counter++)
    {
      Console.WriteLine("intArray[" + counter + "] = " +
        intArray[counter]);
    }

    // char arrays
    char[] charArray = new char[] {'h', 'e', 'l', 'l', 'o'};
    for (int counter = 0; counter < charArray.Length; counter++)
    {
      Console.WriteLine("charArray[" + counter + "] = " +
        charArray[counter]);
    }

    // string arrays
    string[] stringArray = {"Hello", "World"};
    foreach (string myString in stringArray)
    {
      Console.WriteLine("myString = " + myString);
    }

  }

}


           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Collections Data Structure
» Array