Yohan Greenburg Yohan Greenburg - 2 months ago 44
C# Question

Get Min() Value From Int Array

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?

Answer Source
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();