- Beginning C# 7 Hands-On:Advanced Language Features
- Tom Owsiak
- 169字
- 2021-07-02 15:29:25
Defining an expression-bodied member
In the next stage, we will begin by defining an expression member, so enter the following between a set of curly braces:
double FromStringToDouble(string s) => Convert.ToDouble(s);
This line shows a new way of creating functions. That's what this is essentially. Instead of putting curly braces within the line, you can now just put something such as a Lambda expression, => in this case. Then the thing to be converted to a double data type will be the s string. It's also more streamlined; it looks a little more modern, like an expression-bodied member, like a function. Remember that functions are members of classes.
So, in the next stage, we'll define the Button click event below this line. If you go back to the Design view and double-click the button, it'll stick in the following line automatically:
protected void Button1_Click(object sender, EventArgs e)
Next, enter the following between a set of curly braces beneath the preceding line:
string[] vals = TextBox1.Text.Split(new char[] { ',' });
- 少兒人工智能趣味入門:Scratch 3.0動畫與游戲編程
- Delphi程序設計基礎:教程、實驗、習題
- 算法基礎:打開程序設計之門
- 我的第一本算法書
- 精通軟件性能測試與LoadRunner實戰(第2版)
- Python數據結構與算法(視頻教學版)
- Mastering Unity 2D Game Development(Second Edition)
- Machine Learning in Java
- 深入剖析Java虛擬機:源碼剖析與實例詳解(基礎卷)
- OpenCV with Python By Example
- Android應用開發深入學習實錄
- 微信小程序開發實戰:設計·運營·變現(圖解案例版)
- 愛上C語言:C KISS
- C語言程序設計
- 深入解析Java編譯器:源碼剖析與實例詳解