Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/csharp/language-reference/keywords/ref.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 12 additions & 1 deletion docs/csharp/language-reference/operators/assignment-operator.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "= Operator (C# Reference)"
ms.date: 10/31/2018
ms.date: 11/26/2018
f1_keywords:
- "=_CSharpKeyword"
helpviewer_keywords:
Expand All @@ -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.
Expand All @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down