Learn: What is an array class in C#, what are its techniques, properties? This post contains an example of Array class with its techniques and properties.
The array is a class in C#.Net, which is pronounced/characterized in System namespace. Array class has numerous inbuilt techniques and properties, which makes array control (array related tasks) exceptionally simple.
Some of them are, which are ordinarily utilized:
- Sort(array);
- Reverse(array);
- Copy(Source,dest,n);
- GetLength(index)
- Length
Think about the program, which is utilizing every one of these strategies/properties:
using System;
class SDARRAY2
{
static void Main()
{
int [] arr = {80,20,30,12,89,34,1,3,0,8};
for(int i=0;i<arr.Length;i++)
Console.Write(arr[i]+" ");
Console.WriteLine();
Array.Sort(arr);
foreach(int i in arr)
Console.Write(i+" ");
Console.WriteLine();
Array.Reverse(arr);
foreach(int i in arr)
Console.Write(i+" ");
Console.WriteLine();
int []brr = new int [10];
Array.Copy(arr,brr,5);
foreach(int i in brr)
Console.Write(i+" ");
}
}
Output:
80 20 30 12 89 34 1 3 0 8
0 1 3 8 12 20 30 34 80 89
89 80 34 30 20 12 8 3 1 0
89 80 34 30 20 0 0 0 0 0
Press any key to continue . . .
Above example exhibit of the utilization of Array class techniques. Sort() strategy perform arranging, Reverse() technique invert the components of the array and Copy technique is utilized to duplicate one array to another array.