Array sort - ascending , descending
Array sort - C# , VB.Net
Arrays are using for store similar data types grouping as a single unit. Instead of declaring individual variables, such as arr1, arr2, arr3 etc. you declare one array variable such as numbers and use arr, arr, arr etc. to represent individual variables. A specific element in an array is accessed by an index.
Integer Array ExampleC#
String Array ExampleC#
You can sort the arrays in ascending order as well as descending . We can use Array.Sort method for sorts the elements in a one-dimensional array.
How to sort an Integer Array
The following source code shows how to sort an integer Array in ascending order.C#
How to sort a String Array
The following code shows how to sort a string Array in ascending orde.C#
Sort Array in descending order
Above code shows how to sort an Array in ascending order, like that, you can sort an Array in descending order. We can use Array.Reverse method for reverses the sequence of the elements in the entire one-dimensional Array.
Sort an Integer array in descending order
The following code shows how to sort an Integer array in reverse order.C#
Sort a String array in descending order
The following code shows how to sort a string array in reverse order.C#
You can use LINQ OrderByDescending method to reverse an array. OrderByDescending method sorts elements from high to low. The following C# source code shows how to sort an array in descending order by using LINQ OrderByDescending.
Array Example C#, VB.Net
Arrays are using for store similar data types grouping as a single unit. We can access Array elements by its numeric index. The array indexes start at zero. More about.... C# Array , VB.Net Array
How to Create an Array with different data types
You can create an array with elements of different data types when declare the array as Object. Since System.Object is the base class of all other types, an item in an array of Objects can have a reference to any other type of object. More about.... Multiple data types in an Array
NEXT.....Image to Byte Array