- C# 7 and .NET Core Cookbook
- Dirk Strauss
- 130字
- 2021-07-03 00:11:53
Local functions
The use of local functions might seem a little strange at first. They are in fact quite often used in most functional languages. C# 7.0 now allows us to do the same. So what exactly is a local function? Well, think of it as a helper method for a specific method. This helper method only really makes sense when used from the specific method and will not be useful for other methods in your application. It, therefore, makes sense to use it inside your existing method. Some might think that an extension method might be just as well suited, but extension methods should really be used to extend the functionality of many other methods. The usefulness of local functions will become evident in the following code example.
推薦閱讀
- Mastering LibGDX Game Development
- JavaScript動態網頁開發詳解
- concrete5 Cookbook
- R Data Analysis Cookbook(Second Edition)
- Selenium Testing Tools Cookbook(Second Edition)
- C語言程序設計
- IBM Cognos Business Intelligence 10.1 Dashboarding cookbook
- Mastering Akka
- Mastering Python Design Patterns
- 零基礎學C語言程序設計
- 青少年學Python(第2冊)
- 大規模語言模型開發基礎與實踐
- C# 7.1 and .NET Core 2.0:Modern Cross-Platform Development(Third Edition)
- 現代C++語言核心特性解析
- Java EE基礎實用教程