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
-
Below is indexer declaration : modifier return type this [argument list] { get { // Get codes goes here } set { // Set codes goes h...
-
1. An indexer is identified by it's signature. But a property is identified it's name. 2. An indexer is always an instance member,...
-
You can add public events for Httpmodule using below syntax i.e ModuleName_OnEventName in Global.asax . Example Session_OnStart ( Obj...
-
The steps to create custom HTTP module are : Implement IHttpModule Interface Handle Init Method and register events one needs Handle t...
-
Please do below steps to make SQLServer session mode to work properly : 1. To use SQLServer mode, you must first be sure the ASP.NET sessi...
-
Replication is the way to keep data synchronised in multiple datbases. SQL Replication consists of two important part : Publisher - Datab...
-
Different types of primary behaviours are as follows : Service Behaviour Endpoint Behaviour Operation Behaviour Callback Behaviour
-
Cache object belongs to System.Web.Caching namespace.
-
Different security mechanisms used in SQL Server : Logins Users Roles Groups
-
SQL Constraints are used to enforce integrity of database.
No comments:
Post a Comment