Abdalla Omran

Abdalla Omran

  • NA
  • 334
  • 32.4k

How to find the Max or the Highest value in (List) No LINQ

Apr 26 2019 3:29 PM
In this Method returns the TheQFromDB an Instance from the input list where the property SecondsDiff is the highest and in each item in input has a SecondDiff value but one is the highest . how could i find that without using LINQ ? and how could i check all the items . Look at the Code please
public static TheQFromDB CalculateMaxVal (List<TheQFromDB> input)
{
double maxValue = double.MinValue;
foreach (var item in input)
{
if (item.SecondsDiff > maxValue)
{
maxValue = item.SecondsDiff;
}
}
Console.WriteLine(maxValue);
return null;
}
 

Answers (5)