SoFunction
Updated on 2025-03-06

C# method to get the maximum and minimum value in an array

Just get the maximum and minimum value in the array according to the following function. When calling, directly pass a variable of float type in the array range.

 

 public float MaxOfList(float[] flotNum)
    {
      float maxValue = ().Max();

      return maxValue;
    }

    public float MinOfList(float[] flotNum)
    {
      float minValue = ().Max();
      for (int i = 0; i < ; ++i)
      {
        if ((flotNum[i] > -9999.0f) && (minValue > flotNum[i]))
        {
          minValue = flotNum[i];
        }
      }

      return minValue;
    }