Skip to content

Commit 184e4e1

Browse files
BillWagnergewarren
andauthored
Apply suggestions from code review
Co-authored-by: Genevieve Warren <[email protected]>
1 parent d48d407 commit 184e4e1

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ title: "Deconstruction expression - extract properties or fields from a tuple or
33
description: "Learn about deconstruction expressions: expressions that extract individual properties or fields from a tuple or user defined type into discrete expressions."
44
ms.date: 12/17/2024
55
---
6-
# Deconstruction expression - Extract properties of fields from a tuple or other user defined type
6+
# Deconstruction expression - Extract properties of fields from a tuple or other user-defined type
77

88
A *deconstruction expression* extracts data fields from an instance of an object. Each discrete data element is written to a distinct variable, as shown in the following example:
99

1010
:::code language="csharp" source="./snippets/shared/Deconstruction.cs" id="TupleDeconstruction":::
1111

12-
The preceding code snippet creates a [tuple](../builtin-types/value-tuples.md) that has two integer values, `X` and `Y`. The second statement *deconstructs* that tuple and stores the tuple elements in discrete variables `x`, and `y`.
12+
The preceding code snippet creates a [tuple](../builtin-types/value-tuples.md) that has two integer values, `X` and `Y`. The second statement *deconstructs* that tuple and stores the tuple elements in discrete variables `x` and `y`.
1313

1414
## Tuple deconstruction
1515

@@ -23,7 +23,7 @@ In the preceding example, the `Y` and `label` members are discarded. You can spe
2323

2424
## Record deconstruction
2525

26-
[Record](../builtin-types/record.md) types that have a [primary constructor](../builtin-types/record.md#positional-syntax-for-property-definition) support deconstruction for positional parameters. The compiler synthesizes a `Deconstruct` method that extracts the properties synthesized from positional parameters in the primary constructor. The compiler synthesized `Deconstruction` method doesn't extract properties declared as properties in the record type.
26+
[Record](../builtin-types/record.md) types that have a [primary constructor](../builtin-types/record.md#positional-syntax-for-property-definition) support deconstruction for positional parameters. The compiler synthesizes a `Deconstruct` method that extracts the properties synthesized from positional parameters in the primary constructor. The compiler-synthesized `Deconstruction` method doesn't extract properties declared as properties in the record type.
2727

2828
The `record` shown in the following code declares two positional properties, `SquareFeet` and `Address`, along with another property, `RealtorNotes`:
2929

@@ -33,7 +33,7 @@ When you deconstruct a `House` object, all positional properties, and only posit
3333

3434
:::code language="csharp" source="./snippets/shared/Deconstruction.cs" id="RecordDeconstructionUsage":::
3535

36-
You can make use of this behavior to specify which properties of your record types are part of the compiler synthesized `Deconstruct` method.
36+
You can make use of this behavior to specify which properties of your record types are part of the compiler-synthesized `Deconstruct` method.
3737

3838
## Declare `Deconstruct` methods
3939

@@ -43,15 +43,15 @@ The following code declares a `Point3D` struct that has two `Deconstruct` method
4343

4444
:::code language="csharp" source="./snippets/shared/Deconstruction.cs" id="StructDeconstruction":::
4545

46-
The first method supports deconstruction expressions that extract all three axes values: `X`, `Y`, and `Z`. The second method supports deconstructing only the planar values: `X` and `Y`. The first method has an *arity* of 3; the second has an arity of 2.
46+
The first method supports deconstruction expressions that extract all three axis values: `X`, `Y`, and `Z`. The second method supports deconstructing only the planar values: `X` and `Y`. The first method has an *arity* of 3; the second has an arity of 2.
4747

48-
The preceding section described the compiler synthesized `Deconstruct` method for `record` types with a primary constructor. You can declare more `Deconstruct` methods in record types. These methods can either add other properties, remove some of the default properties, or both. You can also declare a `Deconstruct` that matches the compiler synthesized signature. If you declare such a `Deconstruct` method, the compiler doesn't synthesize one.
48+
The preceding section described the compiler-synthesized `Deconstruct` method for `record` types with a primary constructor. You can declare more `Deconstruct` methods in record types. These methods can either add other properties, remove some of the default properties, or both. You can also declare a `Deconstruct` that matches the compiler-synthesized signature. If you declare such a `Deconstruct` method, the compiler doesn't synthesize one.
4949

50-
Typically, multiple `Deconstruct` methods for the same type have different numbers of parameters. You can create multiple `Deconstruct` methods providing the signatures have different parameter types. As long as the compiler can determine one unique `Deconstruct` method for a deconstruction expression, the multiple `Deconstruct` methods are allowed. However, in many cases, too many `Deconstruct` methods can lead to ambiguity errors and misleading results.
50+
Multiple `Deconstruct` methods are allowed as long as the compiler can determine one unique `Deconstruct` method for a deconstruction expression. Typically, multiple `Deconstruct` methods for the same type have different numbers of parameters. You can also create multiple `Deconstruct` methods that differ by parameter types. However, in many cases, too many `Deconstruct` methods can lead to ambiguity errors and misleading results.
5151

5252
## C# language specification
5353

54-
For more information, see the following sections of the [C# Standard](~/_csharpstandard/standard/expressions.md#127-deconstruction):
54+
For more information, see the deconstruction section of the [C# Standard](~/_csharpstandard/standard/expressions.md#127-deconstruction).
5555

5656
## See also
5757

docs/csharp/language-reference/toc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ items:
322322
- name: with expression
323323
href: ./operators/with-expression.md
324324
displayName: "records, copy"
325-
- name: Deconstruction expressions
325+
- name: Deconstruction expression
326326
href: ./operators/deconstruction.md
327327
displayName: deconstruct, deconstruction
328328
- name: Operator overloading

docs/csharp/language-reference/tokens/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ Special characters are predefined, contextual characters that modify the program
2121
- [@](./verbatim.md), the verbatim identifier character.
2222
- [$](./interpolated.md), the interpolated string character.
2323
- ["""](./raw-string.md), A sequence of three or more `"` characters provides the delimiters for a raw string literal.
24-
- [_](./discard.md), a `_` represents a *discard*, a placeholder for an unused variable.
24+
- [_](./discard.md), a `_` character represents a *discard*, which is a placeholder for an unused variable.
2525

2626
This section only includes those tokens that aren't operators. See the [operators](../operators/index.md) section for all operators.

0 commit comments

Comments
 (0)