0

Please note that im not asking if the property can be null or not. but wheter it is declared with nullable modifier.

The nullable modifier is a compile-time feature, and the resulting compiled code does not retain explicit information about whether a property was declared with the nullable modifier.

I have a class

public class MyTest
{
    public string? Nullable { get; set; }
    public string NotNullable { get; set; }
}

Now i would like to write a piece of code that can determine if the property is declared with nullable modifier.

When called it should return true for MyTest.Nullable and false for MyTest.NotNullable

Is it possible?

CruelIO
  • 18,196
  • 16
  • 40
  • 58

0 Answers0