Get rid of the CS8618 warning in visual studio

This warning states that a non nullable property must contain a non null value.

The problem with that warning is that sometimes we populate the property from reflection and we know for sure that the property is not going to be null. One way to deal with it is:


public string MyProperty { get; set; } = default!;

Post a Comment

Previous Post Next Post