Check how you remember nullable value types. Let's peek under the hood

  • Thread starter Thread starter Andrey_Karpov
  • Start date Start date
A

Andrey_Karpov

Guest
Recently nullable reference types have become trendy. Meanwhile, the good old nullable value types are still here and actively used. How well do you remember the nuances of working with them? Let's jog your memory or test your knowledge by reading this article. Examples of C# and IL code, references to the CLI specification, and CoreCLR code are provided. Let's start with an interesting case.

static void NullableTest()
{
int? a = null;
object aObj = a;

int? b = new int?();
object bObj = b;

Console.WriteLine(Object.ReferenceEquals(aObj, bObj)); // True or False?
}



Andrey Karpov is technical manager of the OOO "Program Verification Systems" (Co Ltd) company developing the PVS-Studio tool which is a package of static code analyzers integrating into the Visual Studio development environment.

Continue reading...
 
Back
Top