Comments on: What Does the null! Statement Do? https://code-maze.com/csharp-null-statement/ Learn. Code. Succeed. Mon, 24 Jun 2024 13:26:37 +0000 hourly 1 https://wordpress.org/?v=6.7.5 By: Marinko Spasojević https://code-maze.com/csharp-null-statement/#comment-11036 Mon, 24 Jun 2024 13:26:37 +0000 https://code-maze.com/?p=117090#comment-11036 In reply to Sergio Salanitri.

Hi Sergio.
First, thank you for the great review.
Now, to your question.
As we stated in the article, we can use both the required keyword and the null! statement to mark our properties as not null when working with EF Core.
However, the required keyword is preferred because it forces us to assign a value to a required property during instantiation. If we try to create an instance of our model without assigning a value to our required property, it will raise an exception.
In contrast, the null! statement doesn’t do this. With the null! statement, we can leave our property without a value during instantiation, and we won’t get any warnings or exceptions.

]]>
By: Sergio Salanitri https://code-maze.com/csharp-null-statement/#comment-11010 Mon, 24 Jun 2024 02:01:24 +0000 https://code-maze.com/?p=117090#comment-11010 Great articule, I ask you about the required statement. What is the diferent to mark requirente using null! ?

]]>