- C# 7 and .NET Core Cookbook
- Dirk Strauss
- 117字
- 2021-07-03 00:11:51
How it works...
Tuples are structs, and therefore value types that are created locally. You, therefore, do not have to worry about using and assigning Tuples on-the-fly or that it creating a lot of allocations. Their contents are merely copied when passed. Tuples are mutable and the elements are publicly scoped mutable fields. Using the code example in this recipe, I can, therefore, do the following:
returnTuple = (returnTuple.ave + 15, returnTuple.sCount - 1);
C# 7.0 is allowing me to first update the average value (shifting the average up) and then decrementing the count field. Tuples are a very powerful feature of C# 7.0, and it will be of great benefit to many developers when implemented it correctly.
推薦閱讀
- 程序員面試算法寶典
- Mastering Concurrency in Go
- Learning Elixir
- HTML5+CSS3網站設計教程
- Nexus規模化Scrum框架
- 重學Java設計模式
- Java:High-Performance Apps with Java 9
- 持續輕量級Java EE開發:編寫可測試的代碼
- Learning Node.js for .NET Developers
- Scala編程(第5版)
- Penetration Testing with the Bash shell
- MySQL數據庫應用實戰教程(慕課版)
- Python機器學習開發實戰
- PHP動態網站開發實踐教程
- Python高性能編程(第2版)