From 152a16efb49717932778023d2c8c73f68cc12b3c Mon Sep 17 00:00:00 2001 From: Petr Kulikov Date: Sun, 28 Feb 2021 17:27:43 +0100 Subject: [PATCH 1/2] Discards article: Fix the section about the discard pattern --- docs/csharp/discards.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/csharp/discards.md b/docs/csharp/discards.md index 710d283ba76fa..90130cc3a444d 100644 --- a/docs/csharp/discards.md +++ b/docs/csharp/discards.md @@ -36,9 +36,9 @@ For more information on deconstructing user-defined types with discards, see [De ## Pattern matching with `switch` -The *discard pattern* can be used in pattern matching with the [switch](language-reference/keywords/switch.md) keyword. Every expression always matches the discard pattern. (It can be used with [is](language-reference/keywords/is.md) expressions. However, that use is rare because the discard can be removed without changing its meaning). +The *discard pattern* can be used in pattern matching with the [switch expression](language-reference/operators/switch-expression.md). Every expression always matches the discard pattern. -The following example defines a `ProvidesFormatInfo` method that uses [is](language-reference/keywords/is.md) statements to determine whether an object provides an implementation and tests whether the object is `null`. It also uses the discard pattern to handle non-null objects of any other type. +The following example defines a `ProvidesFormatInfo` method that uses a `switch` expression to determine whether an object provides an implementation and tests whether the object is `null`. It also uses the discard pattern to handle non-null objects of any other type. :::code language="csharp" source="snippets/discards/discard-pattern2.cs" ID="DiscardSwitchExample" ::: From f7a327956df0e8d64d0e50946d3c38d8430ca182 Mon Sep 17 00:00:00 2001 From: Petr Kulikov Date: Mon, 1 Mar 2021 17:27:15 +0100 Subject: [PATCH 2/2] Update docs/csharp/discards.md Co-authored-by: Bill Wagner --- docs/csharp/discards.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/csharp/discards.md b/docs/csharp/discards.md index 90130cc3a444d..686bfc75e86c1 100644 --- a/docs/csharp/discards.md +++ b/docs/csharp/discards.md @@ -36,7 +36,7 @@ For more information on deconstructing user-defined types with discards, see [De ## Pattern matching with `switch` -The *discard pattern* can be used in pattern matching with the [switch expression](language-reference/operators/switch-expression.md). Every expression always matches the discard pattern. +The *discard pattern* can be used in pattern matching with the [switch expression](language-reference/operators/switch-expression.md). Every expression, including `null`, always matches the discard pattern. The following example defines a `ProvidesFormatInfo` method that uses a `switch` expression to determine whether an object provides an implementation and tests whether the object is `null`. It also uses the discard pattern to handle non-null objects of any other type.