- Beginning C# 7 Hands-On:Advanced Language Features
- Tom Owsiak
- 192字
- 2021-07-02 15:29:27
Streamlining writing functions
Within the body, but above the line beginning with protected void Button1_Click..., enter the following:
private void ShowSquare(double x) => sampLabel.Text += "<br>" + (x * x);
Remember, => is an expression member. It's a function. In other words, it takes the form of a Lambda. At the end of the line, we return x * x. As you can see, this is a very streamlined way of writing functions.
Next, we need to add namespaces. So, after using System, enter the following lines:
using System.Collections.Generic; using System.Threading;
Now, within the event for the button, we will place the following code list; so, enter this line between a set of curly braces underneath the line beginning with protected void Button1_Click...:
List<double> vals = new List<double>(new double[] { 1, 2, 4, 5, 6, 8 });
In this line, you are making a new list of double data type and then you will initialize it. You can do this a couple of ways, but you can just write an array and then enter some values. It doesn't really matter what they are. This will make a list of double data types.
- Dynamics 365 for Finance and Operations Development Cookbook(Fourth Edition)
- Java應用與實戰
- 新一代通用視頻編碼H.266/VVC:原理、標準與實現
- Mastering Spring MVC 4
- PLC編程及應用實戰
- Visual C#.NET程序設計
- Mastering ROS for Robotics Programming
- Java面向對象程序設計
- C#程序設計教程(第3版)
- Unity 2018 Augmented Reality Projects
- Java 從入門到項目實踐(超值版)
- Java7程序設計入門經典
- 大學計算機應用基礎(Windows 7+Office 2010)(IC3)
- Web開發的平民英雄:PHP+MySQL
- Java EE項目應用開發