-3

How can i find the highest number from a list of numbers in an array; so far wrote

    int[] data = Utilitybook.Utility.fetchData("book01");
    float result=0;
0

1 Answer 1

0

Use linq to sort your data:

data = data.OrderByDescending(c => c).ToArray();

Then just get your highest and second highest number from it:

int highest = data[0];
int second = data[1];
Sign up to request clarification or add additional context in comments.

2 Comments

If you are going to use LINQ you may as well just do data.Max();
@Svek oh yeah, good point :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.