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

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.

主站蜘蛛池模板: 高平市| 洪湖市| 三原县| 铜川市| 陕西省| 渝北区| 德阳市| 游戏| 休宁县| 时尚| 南城县| 望城县| 新泰市| 灵璧县| 和硕县| 大埔县| 大港区| 广汉市| 上思县| 泰顺县| 资源县| 临漳县| 宁远县| 扎赉特旗| 梧州市| 原阳县| 巫山县| 鲜城| 长阳| 陵水| 黔南| 双江| 陇南市| 阿勒泰市| 金山区| 确山县| 阳谷县| 宁波市| 和林格尔县| 滕州市| 满洲里市|