To do this, we want to find the maximum or minimum value of list <double>, So we write a method.
/// <Summary>
/// Minimum value
/// </Summary>
/// <Param name = "_ series"> </param>
/// <Returns> </returns>
Public static double min (list <double> _ Series)
{
Double result = 0;
Foreach (double item in _ Series)
{
If (result> item)
{
Result = item;
}
}
Return result;
}
It seems that there is no problem, but during the test, it is impossible to show 0 results in the sequence. How can the minimum value be 0? Later, I carefully read this method. The logic is indeed faulty. The initial value of result is 0, which is certainly smaller than any number in the sequence. So we made the following changes:
/// <Summary>
/// Minimum value
/// </Summary>
/// <Param name = "_ series"> </param>
/// <Returns> </returns>
Public static double min (list <double> _ Series)
{
Double result = _ series [0];
Foreach (double item in _ Series)
{
If (result> item)
{
Result = item;
}
}
Return result;
}
Another interesting thing is that Division means that the branch office can be 0. Of course, the result is weird.