Skip to content

Commit 3188a5c

Browse files
authored
Assignment operators: grammar fixes, edits around =ref (#31469)
* Assignment operators: grammar fixes, edits around =ref * Describe example
1 parent 9cd77bd commit 3188a5c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

docs/csharp/language-reference/operators/assignment-operator.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,19 @@ The following example demonstrates the usage of the assignment operator with a l
2828

2929
:::code language="csharp" source="snippets/shared/AssignmentOperator.cs" id="SnippetSimple":::
3030

31-
The left operand of an assignment receives the *value* of the right hand of the assignment. When the operands are [value types](../builtin-types/value-types.md), the assignment copies the contents of the right-hand operand. When the operands are [reference types](../builtin-types/reference-types.md), assignment copies the reference to the object.
31+
The left-hand operand of an assignment receives the *value* of the right-hand operand. When the operands are of [value types](../builtin-types/value-types.md), assignment copies the contents of the right-hand operand. When the operands are of [reference types](../builtin-types/reference-types.md), assignment copies the reference to the object.
3232

3333
This is called *value assignment*: the value is assigned.
3434

3535
## ref assignment
3636

37-
*Ref assignment* assigns the *reference* of its right hand operator to its left hand operand. The left operand is an alias to the right operand. The left operand must be a [ref local](../keywords/ref.md#ref-locals), [ref readonly local](../keywords/ref.md#ref-readonly-locals) or `ref` field in a [`ref struct`]../builtin-types/ref-struct.md). The following example demonstrates the usage of the ref assignment operator:
37+
*Ref assignment* `= ref` makes its left-hand operand an alias to the right-hand operand. The left-hand operand must be a [ref local](../keywords/ref.md#ref-locals), [ref readonly local](../keywords/ref.md#ref-readonly-locals), or a `ref` field in a [`ref struct`](../builtin-types/ref-struct.md). Both operands must be of the same type.
3838

39-
:::code language="csharp" source="snippets/shared/AssignmentOperator.cs" id="SnippetRefAssignment":::
39+
The following example demonstrates the usage of the ref assignment operator:
4040

41-
The `ref` must be applied to the right operands for a ref assignment. Both operands must be of the same type.
41+
:::code language="csharp" source="snippets/shared/AssignmentOperator.cs" id="SnippetRefAssignment":::
4242

43-
This is called *ref assignment*: The variable now refers to a different object.
43+
In the preceding example, the ref local `arrayElement` variable is initialized as an alias to the first array element. Then, it's reassigned to become an alias to the last array element. As it's an alias, when you update its value with an ordinary assignment operator `=`, the corresponding array element is also updated.
4444

4545
## Compound assignment
4646

@@ -78,7 +78,7 @@ For more information about the ref assignment operator `= ref`, see the [feature
7878

7979
## See also
8080

81-
- [Use compound assignment (style rules IDE0054 and IDE0074)](../../../fundamentals/code-analysis/style-rules/ide0054-ide0074.md)
8281
- [C# reference](../index.md)
8382
- [C# operators and expressions](index.md)
8483
- [ref keyword](../keywords/ref.md)
84+
- [Use compound assignment (style rules IDE0054 and IDE0074)](../../../fundamentals/code-analysis/style-rules/ide0054-ide0074.md)

0 commit comments

Comments
 (0)