What is default element initialization of arrays in C#?

 Posted by Goud.Kv on 9/3/2014 | Category: C# Interview questions | Views: 233 | Points: 40

If we have an array which has no initialization of elements such as,
int[] rank = new int[10];
then now if we try to get any element with the array index like,
Console.WriteLine(rank[4]); // prints default value i.e. 0
It will call the default values of the elements.
Default value means the result of bitwise zeroing of the memory.

This process is known as Default Element Initialization of arrays.

Asked In: Spotted While Learning | Alert Moderator 

Comments or Responses

Login to post response