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

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.

主站蜘蛛池模板: 红原县| 洞口县| 花莲市| 眉山市| 金川县| 祁连县| 峨边| 江城| 边坝县| 平安县| 顺昌县| 赤城县| 正镶白旗| 循化| 嘉义县| 庆元县| 巩义市| 蓬溪县| 山西省| 天峨县| 房产| 泰州市| 简阳市| 万宁市| 广西| 静乐县| 迁西县| 万山特区| 巴林右旗| 手机| 泽普县| 太原市| 崇礼县| 遵义县| 平凉市| 淮安市| 泸定县| 金堂县| 郎溪县| 泰安市| 麻江县|