How to get the total number of elements in an array ?

 Posted by Bharathi Cherukuri on 7/30/2012 | Category: C# Interview questions | Views: 2866 | Points: 40
Answer:

By using Length property, we can find the total number of elements in an array.
Below is an example which explains clearly.

Example:

using System;
namespace ConsoleApplication
{
class Program
{
static void Main()
{
int[] Numbers = { 2, 5, 3, 1, 4 };
Console.WriteLine("Total number of elements = " +Numbers.Length);
}
}
}


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response