Introduction to Array in C#







using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace array
{
    class Program
    {
        static void Main(string[] args)
        {
            int  [] a = new int[3]; // array declaration
            int[] b = new int[3] { 30, 40, 50 }; // array initialization
            int[] c = new int[] {30,40,50,70,80,90,88 };


            Console.WriteLine("-------------------------Array A-----------------------");

            for (int i = 0; i < a.Length; i++)
            {
                Console.WriteLine(a[i]);
            }

            Console.WriteLine("-------------------------Array B-----------------------");
            int x = 0;
            while (x < b.Length)
            {
                Console.WriteLine(b[x]);
                x++;
            }
            Console.WriteLine("-------------------------Array C-----------------------");

            foreach (int item in c)
            {
                Console.WriteLine(item);
            }
            Console.ReadLine();
        }
    }
}

Comments