-5

Just posted this code for people that may need it. Because I cannot post the whole code.

Image link

6
  • 1
    Please add your code as text - not an image Commented Jan 27, 2019 at 12:02
  • Also, what do you mean by "top five"? Do you mean the top highest numbers in an array? Commented Jan 27, 2019 at 12:05
  • Possible duplicate of C# find highest array value and index Commented Jan 27, 2019 at 12:06
  • 4
    I'm voting to close this question as off-topic because it's not a question. Stack Overflow is a place to ask questions and get answers - if you want to post code that you've found useful, I'd suggest creating a blog instead. Alternatively, you could ask a question and then post the code as a solution. Commented Jan 27, 2019 at 12:11
  • Why do you want to avoid LINQ? Commented Jan 27, 2019 at 12:15

1 Answer 1

3

Assuming array contains your values:

var array = new List<int>() {33,55}; // fill the array as above
var result = array.OrderByDescending(x => x).Take(5);

Also works for

var array = new int[] { 33, 55 }; // fill the array as above

Lists are preferred to arrays where possible.

Sign up to request clarification or add additional context in comments.

1 Comment

Title was changed after I posted this!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.