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

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.

主站蜘蛛池模板: 长顺县| 台江县| 蒲江县| 浮山县| 大庆市| 穆棱市| 金川县| 福贡县| 札达县| 东平县| 积石山| 康马县| 龙泉市| 隆昌县| 河北省| 思茅市| 白朗县| 永和县| 广汉市| 阳东县| 贵溪市| 彩票| 沙洋县| 水富县| 古蔺县| 泽州县| 施秉县| 阳信县| 浦城县| 自贡市| 平潭县| 巩留县| 大田县| 罗甸县| 宜阳县| 腾冲县| 林口县| 长治县| 称多县| 雷山县| 常宁市|