-1

I am new to Net Core, and today i have read the following code :

public void SomeMethod (object? p1, object? p2, object? p3)

Is not clear to me the meaning of question mark in parameter, in Net Framwork a quotation mark after a non nullable type is used to define it as nullable (eg : DateTime?). But object is a nullable type, so i am confused.

What does it mean? Is there a reference where i can get detail of the new syntax without bother this community?

Skary
  • 1,322
  • 1
  • 13
  • 40

1 Answers1

2

I believe that this is due to changes made in NET 6.

From https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/nullable-reference-types

All project templates starting with .NET 6 (C# 10) enable the nullable context for the project. Projects created with earlier templates don't include this element, and these features are off unless you enable them in the project file or use pragmas.

I suspect that as an object type could be replaced with a any class type that you specifically want to be non-null then this check would also have to apply to it.

ChrisBD
  • 9,104
  • 3
  • 22
  • 35