Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Homework
Please help to solve this case:
There is a project that needs to accept the total number of array elements and values from the user. It also needs to arrange the array elements in ascending order, and display the result. (Hint: The array should be an integer array). How to write the code in C#?
 
-Question by Sun_Shine.. Big Grin | :-D
Posted 7-Mar-11 20:06pm
Edited 8-Mar-11 7:17am
v2
Comments
Marcus Kramer at 8-Mar-11 16:48pm
   
You should do your own homework first, Sun_Shine, and then ask questions specific to issues that arise. You'll be a much better developer in the long run if you fight through issues first and not try to get others to do it for you.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Have a look at the array.sort method:
http://msdn.microsoft.com/en-us/library/aa311213%28VS.71%29.aspx[^]
or see this link with a lot of samples:
http://www.csharp-examples.net/sort-array/[^]
  Permalink  
Comments
Espen Harlinn at 13-Mar-11 8:53am
   
Nice and simple, my 5
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

int[] array = new int[] { 3, 1, 4, 5, 2 };
 

 
//Declare Array
 

 
Array.Sort<int>( array );
 

 
// Sort Method used Asending Order
 

 
Array.Reverse( array );
 

 
// reverse Method used Decenting Order
  Permalink  
Comments
ThePhantomUpvoter at 20-Apr-13 10:57am
   
You are only 2 years too late to do the OP's homework for them.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 George Jonsson 215
1 Kornfeld Eliyahu Peter 169
2 OriginalGriff 120
3 PIEBALDconsult 110
4 BillWoodruff 85
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,294


Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 20 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100