官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 江孜县| 彭阳县| 巧家县| 都兰县| 邳州市| 和政县| 长汀县| 红安县| 嫩江县| 东方市| 原平市| 嵊泗县| 泌阳县| 大足县| 咸阳市| 津市市| 许昌县| 汉源县| 平南县| 瓮安县| 新乐市| 夏河县| 舟山市| 伊宁市| 禄丰县| 桑植县| 中牟县| 兰溪市| 宜州市| 兴隆县| 南郑县| 华容县| 鄂伦春自治旗| 五华县| 云霄县| 静乐县| 平顶山市| 扎赉特旗| 库尔勒市| 东宁县| 清镇市|