- Beginning C# 7 Hands-On:Advanced Language Features
- Tom Owsiak
- 135字
- 2021-07-02 15:29:25
Creating an expression-bodied lambda
Next, you'll define the body of the Lambda. Because this lambda will do several things, you can enclose the body of it within a set of curly braces as follows:
{
double x = xin, y = yin;
}
So, this line assigns the values from the parameters above.
Next enter the following directly below this line:
return x > y ? x : y;
So, if x is greater than y, then return x; otherwise, return y. This is an expression-bodied Lambda, and you close it at the end with a semicolon after the closed curly brace, like this };. As you can see, this Lambda expression spans multiple lines. So, you can again inline code just as with the preceding line, using the double FromStringToDouble(string s) => Convert.ToDouble(s); function.
推薦閱讀
- Dynamics 365 for Finance and Operations Development Cookbook(Fourth Edition)
- Java范例大全
- Python量化投資指南:基礎、數據與實戰
- Java系統分析與架構設計
- Java完全自學教程
- Vue.js前端開發基礎與項目實戰
- C#完全自學教程
- Hands-On RESTful Web Services with Go
- Spring實戰(第5版)
- 單片機應用與調試項目教程(C語言版)
- WordPress 4.0 Site Blueprints(Second Edition)
- 常用工具軟件立體化教程(微課版)
- Getting Started with React Native
- Fast Data Processing with Spark(Second Edition)
- Scratch·愛編程的藝術家