1

I am creating an int array by using the below syntax

int start = Math.Min(Convert.ToInt32(FirstNum), Convert.ToInt32(SecondNum));
int end = Math.Max(Convert.ToInt32(FirstNum), Convert.ToInt32(SecondNum));
end = end + 1;
int[] ang = Enumerable.Range(start, end - start).ToArray();
foreach (int a in ang) {int first = a.Min(); }

However I have a compile error of

'int' does not contain a definition for 'Min' and the best extension method overload 'Enumerable.Min(IEnumerable)' requires a receiver of type 'IEnumerable'

What is the proper way to get the MIN() value from the array of ints?

5
  • @Vanna - good catch! I am needing to check the array not the individual item from the array. I also need to set it to int first == a.Min(); Commented Aug 27, 2017 at 23:18
  • You do not need the loop. Use just int first = ang.Min(); and get rid of the loop. Commented Aug 27, 2017 at 23:26
  • 2
    Since the elements are already in ascending order, ang[0] is the minimum element. Commented Aug 27, 2017 at 23:28
  • @Vanna, post this as an answer. Commented Aug 28, 2017 at 0:14
  • Fair enough :-) Commented Aug 28, 2017 at 0:27

1 Answer 1

1
int start = Math.Min(Convert.ToInt32(FirstNum), Convert.ToInt32(SecondNum));
int end = Math.Max(Convert.ToInt32(FirstNum), Convert.ToInt32(SecondNum));
end = end + 1;
int[] ang = Enumerable.Range(start, end - start).ToArray();

var minimumValue = ang.Min();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.