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

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.

主站蜘蛛池模板: 汶川县| 丹东市| 澄江县| 溧水县| 滨州市| 眉山市| 图木舒克市| 千阳县| 赞皇县| 无锡市| 达日县| 武定县| 富民县| 民权县| 嘉禾县| 汉源县| 中西区| 吉木萨尔县| 蚌埠市| 苗栗市| 和政县| 九台市| 扬州市| 安溪县| 龙江县| 岑溪市| 宿迁市| 乳山市| 晋中市| 勐海县| 珲春市| 博客| 金堂县| 安阳县| 怀安县| 韶山市| 曲周县| 会宁县| 茂名市| 玉屏| 临安市|