Skip to content

Commit 5d0692c

Browse files
pkulikovBillWagner
andauthored
Null-forgiving and null-conditional interaction is fixed (#21531)
Co-authored-by: Bill Wagner <[email protected]>
1 parent 8dcd395 commit 5d0692c

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

docs/csharp/language-reference/operators/member-access-operators.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Member access operators and expressions - C# reference"
33
description: "Learn about C# operators that you can use to access type members."
4-
ms.date: 04/17/2020
4+
ms.date: 11/13/2020
55
author: pkulikov
66
f1_keywords:
77
- "._CSharpKeyword"
@@ -132,9 +132,6 @@ In the preceding example, if you don't use the `??` operator, `numbers?.Length <
132132

133133
The null-conditional member access operator `?.` is also known as the Elvis operator.
134134

135-
> [!NOTE]
136-
> In C# 8, the [null-forgiving operator](null-forgiving.md) terminates the list of preceding null-conditional operations. For example, the expression `x?.y!.z` is parsed as `(x?.y)!.z`. Due to this interpretation, `z` is evaluated even if `x` is `null`, which may result in a <xref:System.NullReferenceException>.
137-
138135
### Thread-safe delegate invocation
139136

140137
Use the `?.` operator to check if a delegate is non-null and invoke it in a thread-safe way (for example, when you [raise an event](../../../standard/events/how-to-raise-and-consume-events.md)), as the following code shows:

docs/csharp/language-reference/operators/null-forgiving.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
description: "! (null-forgiving) operator - C# reference"
33
title: "! (null-forgiving) operator - C# reference"
4-
ms.date: 10/11/2019
5-
f1_keywords:
4+
ms.date: 11/13/2020
5+
f1_keywords:
66
- "nullForgiving_CSharpKeyword"
77
helpviewer_keywords:
88
- "null-forgiving operator [C#]"
@@ -14,9 +14,6 @@ Available in C# 8.0 and later, the unary postfix `!` operator is the null-forgiv
1414

1515
The null-forgiving operator has no effect at run time. It only affects the compiler's static flow analysis by changing the null state of the expression. At run time, expression `x!` evaluates to the result of the underlying expression `x`.
1616

17-
> [!NOTE]
18-
> In C# 8, the null-forgiving operator terminates the list of preceding [null-conditional](member-access-operators.md#null-conditional-operators--and-) operations. For example, the expression `x?.y!.z` is parsed as `(x?.y)!.z`. Due to this interpretation, `z` is evaluated even if `x` is `null`, which may result in a <xref:System.NullReferenceException>.
19-
2017
For more information about the nullable reference types feature, see [Nullable reference types](../builtin-types/nullable-reference-types.md).
2118

2219
## Examples

0 commit comments

Comments
 (0)