CSharp - What is the output: array initialization?


What is the output of the following code?

using System;
class MainClass
   public static void Main(string[] args)

       int[] ints = new int[2];
       Console.WriteLine (ints[0]);    


Click to view the answer



Array elements are automatically initialized with the default values for their type.

The code outputs 0, because array elements are implicitly assigned to their default values.