Relative Content

Tag Archive for c#object-oriented-analysisnullable-reference-types

How to do null check in constructor and properties in C#?

I am getting a warning from the compiler about my code. I don’t know why because I have checked it in the property setter. If I check this in the constructor, the warning disappears, but then I have to write the same code twice, which is not good. Can someone explain to me how I should write this class? I want to know what is the right way to do this?