Review C # Methods Math. Max and Math. Min,
Learn Math. Max and Min today. For both methods, two parameters are required. The maximum and minimum values of the two parameters are returned.
Class Ac {public void LeanMathFunction () {int min = Math. min (5, 3); Console. writeLine ("5, 3 Min min Min: {0}", min); int max = Math. max (25, 37); Console. writeLine ("25, 37 Max: {0}", max) ;}} Source Code
Result of running the program on the console:
What if you want to find the maximum or minimum values in a group of numbers?
At this time, you can refer to several methods to find the maximum and minimum values in the integer array http://www.cnblogs.com/insus/p/7975685.html
However, there are some changes to the Class4 in the link in Insus. NET. use Math. Max and Math. Min to replace the values greater than (>) or less than (<) and change them:
Insus. NET development habits, can not use if.
Next, we need to test whether the above method is correct:
Declare a private attribute and a constructor. The constructor accepts a set of data and an output method: