save up to 40%

How to create and sort an array of data?

Are you preparing for IT certification? With practice questions, study notes, interactive quizzes, tips and technical articles, uCertify PrepKits ensure that you get a solid grasp of core technical concepts to ace your certification exam in first attempt.

How to create and sort an array of data?

Rating:

The three steps to create and sort an array of data are as follows:

  1. Firstly, declare and initialize an array of data. An array of data is declared by using a value data type with square braces and a variable name in which the array of data is to be stored. An example is given below:
    int[] array1 = {12, 16, 18, 22};


  2. Secondly, call the Sort method of the Array class in the System namespace. The Array class of the System namespace provides different methods to create, manipulate, search, and sort an array of data. It serves as the base class for an array of data in the common language runtime. The Sort method sorts the data elements in one-dimensional array. It is declared in an Array object. An example is given below:

    Array.Sort(array1);


  3. Lastly, display the result on the console. The Console.WriteLine method writes a text that represents the specified object to the standard output stream or to a console. An example is given below:

    Console.WriteLine("{0}, {1}, {2}, {3}", array1[0], array1[1], array1[2], array1[3]);


Rating:



Other articles

Click here to Article home

 
uCertify.com | Our Company | Articles | Privacy | Security | Contact Us | News and Press Release | uCertify India
MCSE: MCSA, MCTS, MCITP    JAVA Certification: SCJP, SCWCD Cisco Certification: CCNA, CCENT, A+, Network+, Security+
Oracle Certification: OCP 9i, OCP 10g, OCA 9i, OCA 10g CIW foundation    EC-212-32    CISSP    Photoshop ACE    Adobe Flash ACE
© 2008 uCertify.com. All rights reserved. All trademarks are the property of their respective owners.