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