diff --git a/docs/csharp/language-reference/keywords/ref.md b/docs/csharp/language-reference/keywords/ref.md index 635bf938832ff..a7d353e01f8b4 100644 --- a/docs/csharp/language-reference/keywords/ref.md +++ b/docs/csharp/language-reference/keywords/ref.md @@ -151,6 +151,7 @@ You can combine modifiers to declare a struct as `readonly ref`. A `readonly ref - [Write safe efficient code](../../write-safe-efficient-code.md) - [Ref returns and ref locals](../../programming-guide/classes-and-structs/ref-returns.md) - [Conditional ref expression](../operators/conditional-operator.md#conditional-ref-expression) +- [ref assignment operator](../operators/assignment-operator.md#ref-assignment-operator) - [Passing Parameters](../../programming-guide/classes-and-structs/passing-parameters.md) - [Method Parameters](method-parameters.md) - [C# Reference](../index.md) diff --git a/docs/csharp/language-reference/operators/assignment-operator.md b/docs/csharp/language-reference/operators/assignment-operator.md index 47051e545e939..57837788248de 100644 --- a/docs/csharp/language-reference/operators/assignment-operator.md +++ b/docs/csharp/language-reference/operators/assignment-operator.md @@ -1,6 +1,6 @@ --- title: "= Operator (C# Reference)" -ms.date: 10/31/2018 +ms.date: 11/26/2018 f1_keywords: - "=_CSharpKeyword" helpviewer_keywords: @@ -27,6 +27,16 @@ The following example demonstrates the usage of the assignment operator to assig [!code-csharp-interactive[assignment operator](~/samples/snippets/csharp/language-reference/operators/AssignmentExamples.cs#Assignments)] +## ref assignment operator + +Beginning with C# 7.3, you can use the ref assignment operator `= ref` to reassign a [ref local](../keywords/ref.md#ref-locals) or [ref readonly local](../keywords/ref.md#ref-readonly-locals) variable. The following example demonstrates the usage of the ref assignment operator: + +[!code-csharp[ref assignment operator](~/samples/snippets/csharp/language-reference/operators/AssignmentExamples.cs#RefAssignment)] + +In the case of the ref assignment operator, the type of the left operand and the right operand must be the same. + +For more information, see the [feature proposal note](https://github.com/dotnet/csharplang/blob/master/proposals/csharp-7.3/ref-local-reassignment.md). + ## Operator overloadability A user-defined type cannot overload the assignment operator. However, a user-defined type can define an implicit conversion to another type. That way, the value of a user-defined type can be assigned to a variable, a property, or an indexer element of another type. For more information, see the [implicit](../keywords/implicit.md) keyword article. @@ -40,3 +50,4 @@ For more information, see the [Simple assignment](~/_csharplang/spec/expressions - [C# Reference](../index.md) - [C# Programming Guide](../../programming-guide/index.md) - [C# Operators](index.md) +- [ref keyword](../keywords/ref.md) diff --git a/docs/csharp/language-reference/operators/conditional-operator.md b/docs/csharp/language-reference/operators/conditional-operator.md index f43dfd87bc5f0..b64732e9aea30 100644 --- a/docs/csharp/language-reference/operators/conditional-operator.md +++ b/docs/csharp/language-reference/operators/conditional-operator.md @@ -42,7 +42,7 @@ The following example demonstrates the usage of the conditional operator: ## Conditional ref expression -Beginning with C# 7.2, you can use the conditional ref expression to return the reference to the result of one of the two expressions. You can assign that reference to a [local ref](../keywords/ref.md#ref-locals) or [local ref readonly](../keywords/ref.md#ref-readonly-locals) variable, or use it as a [reference return value](../keywords/ref.md#reference-return-values) or as a [`ref` method parameter](../keywords/ref.md#passing-an-argument-by-reference). +Beginning with C# 7.2, you can use the conditional ref expression to return the reference to the result of one of the two expressions. You can assign that reference to a [ref local](../keywords/ref.md#ref-locals) or [ref readonly local](../keywords/ref.md#ref-readonly-locals) variable, or use it as a [reference return value](../keywords/ref.md#reference-return-values) or as a [`ref` method parameter](../keywords/ref.md#passing-an-argument-by-reference). The syntax for the conditional ref expression is as follows: