Sort And Reverse Method (Static Methods In Array Class)
Syntax for Sort Method is : - Sort(arrayname)
Syntax for Reverse Method is :- Reverse(arrayname)
------------------------------------------------------------------------------------------------------
using System;
class ReverseAndSortMethod
{
static void Main()
{
int[] arr = {32,45,67,23,65,3,45,23};
Console.WriteLine("Array before reserve and sort");
Console.WriteLine("--------------------------------------");
foreach(int i in arr)
{ Console.Write(i + "\t"); }
Console.WriteLine("\n--------------------------------------");
Array.Sort(arr);
Console.WriteLine("Array before reserve and after sort");
Console.WriteLine("--------------------------------------");
foreach(int i in arr)
{ Console.Write(i + "\t"); }
Console.WriteLine("\n--------------------------------------");
Array.Reverse(arr);
Console.WriteLine("Array after reserve and after sort");
foreach(int i in arr)
{ Console.Write(i + "\t"); }
Console.WriteLine("\n--------------------------------------");
}
}
------------------------------------------------------------------------------------------------------
Sort And Reverse Method (Static Methods In Array Class)
Reviewed by Baljeet Singh
on
08:02
Rating:
No comments: