28 lines
898 B
Plaintext
28 lines
898 B
Plaintext
:null-keyword: null
|
|
:null-keyword-link: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/null
|
|
:language: csharp
|
|
|
|
include::../why-dotnet.adoc[]
|
|
|
|
==== Null forgiving operator
|
|
|
|
Expression marked with the https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/null-forgiving[null forgiving operator]
|
|
|
|
[source,csharp]
|
|
----
|
|
public void Method()
|
|
{
|
|
object o = null;
|
|
o!.ToString(); // Compliant: the null forgiving operator suppresses the nullable warning
|
|
}
|
|
----
|
|
|
|
include::../how-dotnet.adoc[]
|
|
|
|
include::../resources-dotnet.adoc[]
|
|
|
|
* 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)]
|
|
|
|
include::../rspecator-dotnet.adoc[]
|