官术网_书友最值得收藏!

Running the program

What you have here is very sophisticated code. Now crank it up in your browser, and take a look at the results. Enter some values, say 1,5, and -3, and click on the Find Max button. The result is 5, as you can see in Figure 7.2.3:

Figure 7.2.3: Preliminary results of running the program with pure integer values

Next, enter something such as 1.01, 1.02, and 0.9999, and click on the Find Max button. The result is 1.02, as you can see in Figure 7.2.4:

Figure 7.2.4: Results of running the program with extended decimal values

So, the program is working as expected.

Again, to review, because there's a lot of code here, we did the following in this program:

  1. First, we declared a delegate.
  2. Then we declared an expression-bodied member, which, in this context of this code, is a function that's defined essentially with a Lambda.
  3. Next, we made an array of values.
  1. Then we created a line to convert the values from a string type to a double type.
  2. After that, we made an expression-bodied Lambda.
  3. Then we built a function called CompareValuesInList that takes that Lambda as an argument and then also looks at the other values.
  4. Finally, CompareValuesInList is where the magic really happens, because it says that, if the third value is bigger than either of the two first compared, then you return the third value. However, if it's not, then simply return the one that is the bigger of the first two.

I know this doesn't seem like an easy thing to do. I know this because I've done this before. You must absolutely add this level of coding, however. Type it, run it, and process it; then you will develop your understanding quickly enough. These are the fundamentals of making some of this stuff useful.

主站蜘蛛池模板: 金塔县| 长白| 安新县| 昆山市| 江川县| 古交市| 沂南县| 邯郸市| 灵璧县| 会东县| 会宁县| 通辽市| 胶州市| 鄄城县| 怀宁县| 沛县| 盐源县| 滨州市| 蒙城县| 集贤县| 读书| 额尔古纳市| 武汉市| 栾川县| 张家界市| 沈丘县| 新津县| 望城县| 云霄县| 读书| 平远县| 井陉县| 武胜县| 祁阳县| 锡林郭勒盟| 星座| 黄平县| 永春县| 阿鲁科尔沁旗| 白河县| 巫山县|