If I have a large collection and care about performance, I have to believe in miracles and use
var min = Y.Min();
var max = Y.Max();
or better to be a good engineer and use
var max = double.NegativeInfinity;
var min = double.PositiveInfinity;
foreach(var y in Y)
{
if(y > max)
max = y;
if(y < min)
min = y;
}
Y ICollection<double>because I need Countand foreach. I am curious if the type is right, due to min / max and that I will need to iterate the collection from the end, so that will be
Y.OrderByDescending((o) => o)...
source
share