We can sort array of primitive types using Array.Sort() and Array.Reverse() in ascending and descending order
Example :
// sort int array in ascending order
int[] intArray = new int[5] { 8, 10, 2, 6, 9 };
Array.Sort(intArray);
// write array
foreach (int i in intArray) Console.Write(i + " "); // output: 2 6 8 9 10
// sort int array in descending order
int[] intArray = new int[5] { 8, 10, 2, 6, 9 };
Array.Sort(intArray);
Array.Reverse(intArray);
// write array
foreach (int i in intArray) Console.Write(i + " "); // output: 10 9 8 6 2
Subscribe to:
Post Comments (Atom)
Popular Posts
-
New Data types in SQL Server 2008 are : DATE - occupies 3 bytes . Has accuracy of 1 day . Data stored in 'YYYY-MM-DD' format TIME...
-
Authentication is process of obtaining credentials such as username and password and validating the credentials. There are 3 types of ASP....
-
Question : State whether below class relationship is correct or not . If not why ? class A: B {} class B: C {} class C: A {} Answer...
-
Different validation controls in ASP.NET are as follows : RequiredFieldValidator CompareValidator RangeValidator RegularExpressionValida...
-
How to pass null values to stored procedure from code behind ? Pass the parameter’s value as DBNull.Value from code-behind.
-
Different types of primary behaviours are as follows : Service Behaviour Endpoint Behaviour Operation Behaviour Callback Behaviour
-
Cache object belongs to System.Web.Caching namespace.
-
Custom HTTPmodule is created for: URL rewriting Compression Specialized authentication and authorization Specialized logging
-
Types of DML statements : Select Insert Update Delete
-
Question : You and a group of programmers have written a new web application using Visual Studio.NET for a new client. The application trac...
No comments:
Post a Comment