Home > DeveloperSection > Forums > Array in c#.
Ankit Singh

Total Post:341

Points:2389
Posted on    November-03-2015 10:01 PM

 .NET C# 
Ratings:


 1 Reply(s)
 324  View(s)
Rate this:
How to use array in c#.


aditya kumar Patel

Total Post:247

Points:1759
Supported
Posted on    November-03-2015 10:08 PM

Arrays are used to store data of our applications. We declare arrays to be of a certain data type. We specify their length. And we initialize arrays with data. We have several methods for working with arrays. We can modify the elements, sort them, copy them or search for them.

using System;

using System.Collections.Generic;

using System.Diagnostics;

using System.Linq;

using System.Net;

using System.Text;

using System.Threading;

namespace Forum

{

 

public class ChildClass

{

 

static void Main(string[] args)

{

int[] array = new int[5];

array[0] = 1;

array[1] = 2;

array[2] = 3;

array[3] = 4;

array[4] = 5;

Console.WriteLine("Show Array Numbers");

for (int i = 0; i < array.Length; i++)

{

Console.WriteLine(array[i]);

}

string[] names = { "ashish", "Tarun", "Pawan", "David" };

Console.WriteLine("Show Array Name");

Console.WriteLine(names[0]);

Console.WriteLine(names[1]);

Console.WriteLine(names[2]);

Console.WriteLine(names[3]);

Console.ReadLine();

}

}

}


Don't want to miss updates? Please click the below button!

Follow MindStick