Default array initializing

When you create an array, C# initializes the value for each element.

 
using System;

class Program
{
    static void Main(string[] args)
    {
        int[] intArray = new int[10];

        for (int i = 0; i < intArray.Length; i++)
        {
            Console.WriteLine(intArray[i]);
        }

    }
}
  

The output:


0
0
0
0
0
0
0
0
0
0
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.