Skip to content

Commit ca94fa1

Browse files
BillWagnergewarren
andauthored
Make it more clear that a positional pattern relies on Deconstruct (dotnet#42514)
* Make it more clear that a positional pattern relies on `Deconstruct` Fixes dotnet#42307 * Update docs/csharp/language-reference/operators/patterns.md Co-authored-by: Genevieve Warren <[email protected]> --------- Co-authored-by: Genevieve Warren <[email protected]>
1 parent fadc9f2 commit ca94fa1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

docs/csharp/language-reference/operators/patterns.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,12 @@ You use a *positional pattern* to deconstruct an expression result and match the
195195

196196
:::code language="csharp" source="snippets/patterns/PositionalPattern.cs" id="BasicExample":::
197197

198-
At the preceding example, the type of an expression contains the [Deconstruct](../../fundamentals/functional/deconstruct.md) method, which is used to deconstruct an expression result. You can also match expressions of [tuple types](../builtin-types/value-tuples.md) against positional patterns. In that way, you can match multiple inputs against various patterns, as the following example shows:
198+
At the preceding example, the type of an expression contains the [Deconstruct](../../fundamentals/functional/deconstruct.md) method, which is used to deconstruct an expression result.
199+
200+
>[!IMPORTANT]
201+
> The order of members in a positional pattern must match the order of parameters in the `Deconstruct` method. That's because the code generated for the positional pattern calls the `Deconstruct` method.
202+
203+
You can also match expressions of [tuple types](../builtin-types/value-tuples.md) against positional patterns. In that way, you can match multiple inputs against various patterns, as the following example shows:
199204

200205
:::code language="csharp" source="snippets/patterns/PositionalPattern.cs" id="MatchTuple":::
201206

0 commit comments

Comments
 (0)