Review C # Methods Math. Max and Math. Min,

Source: Internet
Author: User

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:

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.