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

Pattern matching

C# 7.0 introduces an aspect common to functional programming languages with pattern matching. This new kind of construct can test values in different ways. To accomplish this, two language constructs in C# 7.0 have been enhanced to take advantage of patterns. These are as follows:

  • The is expression
  • The case clause in switch statements

With regard to the is expression, developers can now have a pattern on the right instead of just a type. When it comes to switch statements, the case clause can now match on patterns. The switch statement is no longer limited to primitive types and can switch on anything. Let's start by looking at the is expression.

主站蜘蛛池模板: 探索| 米泉市| 米脂县| 平遥县| 银川市| 隆昌县| 潞城市| 广宁县| 衡山县| 伊宁市| 克什克腾旗| 渭源县| 昌邑市| 奎屯市| 乌海市| 澎湖县| 昌乐县| 阳信县| 元谋县| 苏尼特左旗| 建昌县| 平潭县| 进贤县| 东平县| 富民县| 博乐市| 遵义县| 永靖县| 潞西市| 九寨沟县| 三门县| 阳信县| 长海县| 博客| 定边县| 兴文县| 光山县| 溧阳市| 赞皇县| 仁寿县| 建湖县|