- C# 7 and .NET Core 2.0 Blueprints
- Dirk Strauss Jas Rademeyer
- 240字
- 2021-08-27 19:55:24
Summary
C# 7 is a fantastic version of the language. In this chapter, we had a look at out variables. You will remember that with C# 7 we now have the ability to declare the variable right at the point it is passed as an out argument. We then looked at tuples, which provide an elegant way to return multiple values from a method.
Moving, on we looked at expression-bodied properties, which is a more succinct way to write your code. Then, we discussed local functions (one of my favorite features) and its ability to create a helper function inside another function. This makes sense if the function that uses the local function is the only code that uses it.
Pattern matching was up next and are syntactic elements that look to see if a specific value has a certain shape. This makes switch statements (for example) nicer to use. Lastly, we looked at throw expressions. This makes it possible to add exception throwing to our expression-bodied members, conditional and null-coalescing expressions.
As you continue to use C# 7, you will discover more opportunities to use these new features. At first (for me anyway) I had to purposefully condition myself to write code using a new feature (out variables being a perfect example).
After a while, the convenience of doing that becomes second nature. You will soon start to automatically write code using the new features available to you.
- HTML5+CSS3王者歸來
- Three.js開發指南:基于WebGL和HTML5在網頁上渲染3D圖形和動畫(原書第3版)
- 算法基礎:打開程序設計之門
- Python Game Programming By Example
- Java程序設計與計算思維
- Processing互動編程藝術
- 差分進化算法及其高維多目標優化應用
- 微信小程序開發解析
- Learning Vaadin 7(Second Edition)
- Java系統化項目開發教程
- Java網絡編程核心技術詳解(視頻微課版)
- 微信小程序開發與實戰(微課版)
- Building Wireless Sensor Networks Using Arduino
- Modern C++ Programming Cookbook
- Visual C++從入門到精通(第2版)