2023-07-03 17:26:15 +02:00
|
|
|
:null-keyword: null
|
|
|
|
:null-keyword-link: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/null
|
|
|
|
:language: csharp
|
2023-05-03 11:06:20 +02:00
|
|
|
|
2023-07-03 17:26:15 +02:00
|
|
|
include::../why-dotnet.adoc[]
|
2020-06-30 12:48:07 +02:00
|
|
|
|
2023-07-03 17:26:15 +02:00
|
|
|
==== Null forgiving operator
|
2020-06-30 12:48:07 +02:00
|
|
|
|
2023-07-03 17:26:15 +02:00
|
|
|
Expression marked with the https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/null-forgiving[null forgiving operator]
|
2022-09-05 08:04:25 +02:00
|
|
|
|
|
|
|
[source,csharp]
|
|
|
|
----
|
|
|
|
public void Method()
|
2020-06-30 12:48:07 +02:00
|
|
|
{
|
2023-07-03 17:26:15 +02:00
|
|
|
object o = null;
|
|
|
|
o!.ToString(); // Compliant: the null forgiving operator suppresses the nullable warning
|
2020-06-30 12:48:07 +02:00
|
|
|
}
|
|
|
|
----
|
|
|
|
|
2023-07-03 17:26:15 +02:00
|
|
|
include::../how-dotnet.adoc[]
|
2021-09-20 15:38:42 +02:00
|
|
|
|
2023-07-03 17:26:15 +02:00
|
|
|
include::../resources-dotnet.adoc[]
|
2021-06-02 20:44:38 +02:00
|
|
|
|
2023-07-03 17:26:15 +02:00
|
|
|
* Microsoft Learn - https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/null[null (C# Reference)]
|
|
|
|
* Microsoft Learn - https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/null-forgiving[! (null-forgiving) operator (C# reference)]
|
2023-06-22 10:38:01 +02:00
|
|
|
|
2023-07-03 17:26:15 +02:00
|
|
|
include::../rspecator-dotnet.adoc[]
|