- 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.
推薦閱讀
- Extending Jenkins
- jQuery Mobile Web Development Essentials(Third Edition)
- Oracle從新手到高手
- Vue.js快跑:構建觸手可及的高性能Web應用
- Neo4j Essentials
- Mastering LibGDX Game Development
- 征服RIA
- 微信公眾平臺開發:從零基礎到ThinkPHP5高性能框架實踐
- JS全書:JavaScript Web前端開發指南
- Unreal Engine 4 Shaders and Effects Cookbook
- Building Serverless Applications with Python
- Visual C++開發入行真功夫
- Android智能手機APP界面設計實戰教程
- 零基礎PHP從入門到精通
- 軟技能2:軟件開發者職業生涯指南