var maxHeight = draw._shapes.Aggregate((agg, next) =>next.height > agg.height ? next : agg); if (draw._shapes.Count == 0) trackBar_Size.Maximum = 484; else { foreach (float heights in maxHeight) { if (heights < 412) { trackBar_Size.Maximum = 484; } else if (heights > 412) { trackBar_Size.Maximum = 415; } } } Error 3 foreach statement cannot operate on variables of type 'sCreator.Shape' because 'sCreator.Shape' does not contain a public definition for 'GetEnumerator'
I got this error on the var maxHeight statement. So how do I fix this error and use the LINQ result as a float value?
Aggregatedoesn't return collection, it returns scalar value. See also: stackoverflow.com/questions/7105505/….