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

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.

主站蜘蛛池模板: 肥乡县| 黄浦区| 乌鲁木齐市| 潍坊市| 沅陵县| 广河县| 宜宾市| 修水县| 宝清县| 汾阳市| 朝阳区| 佛冈县| 建宁县| 宽城| 宁陵县| 曲沃县| 麻城市| 达拉特旗| 连州市| 台北市| 荆州市| 扶风县| 新郑市| 西昌市| 固阳县| 平潭县| 湖北省| 香格里拉县| 大城县| 峡江县| 贡嘎县| 吴旗县| 滦南县| 石景山区| 温泉县| 石屏县| 庄浪县| 安泽县| 华亭县| 红安县| 奉化市|