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

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.

主站蜘蛛池模板: 沁源县| 甘泉县| 凤台县| 定南县| 酉阳| 双牌县| 宁武县| 祁门县| 南充市| 班玛县| 岫岩| 鹤山市| 南溪县| 黄陵县| 安多县| 区。| 邢台市| 运城市| 葫芦岛市| 明溪县| 惠安县| 红桥区| 黄龙县| 镇康县| 北碚区| 丰县| 承德县| 阿克| 原阳县| 丰原市| 都江堰市| 长沙县| 双鸭山市| 彰化县| 桐庐县| 宜章县| 即墨市| 澄城县| 武城县| 和静县| 邹平县|