Array list using ascending order descending order in C#
Array List AscOrder:
//Array Sort
Array.Sort<int>(value);
Array.Sort<int>(i);
Array List DescOrder:
//Array Sort Reverse
Array.Sort<int>(i);
Array.Reverse(i);
Array List AscOrder C#:
public void ArrayAsc()
{
int[] i = { 10, 30, 5, 7 };
//Array Sort
Array.Sort<int>(i);
foreach (int A in i)
{
Response.Write(A+",");
}
}
Ans:
Ascending Order = 5,7,10,30
---------------------------------------------------------
Array List DescOrder C#:
public void ArrayDesc()
{
int[] i = { 10, 30, 5, 7 };
Array.Sort<int>(i); //First Sort Order Asc Next Reverse using Desc
//Array Sort Desc
Array.Reverse(i);
foreach (int A in i)
{
Response.Write(A+",");
}
}
Ans:
Descending Order = 30,10,7,5
No comments:
Post a Comment