Sep 20, 2011

C# program to count the total numbers of elements in the array

using System;

namespace arrayDemo
{
    class Program
    {
       unsafe static void Main(string[] args)
        {
          
           int[] arr={10,20,30,40};
           int count;

           //To count the total numbers of elements in the array
           count = arr.Length;

          //To print the value of count
           Console.WriteLine("Length of the array is: {0}", count);
           Console.ReadKey();
        }
    }
}

Output: Length of the array is: 4

No comments:

Post a Comment