Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine if type reference is nullable/non-nullable

Using the upcoming C# 8 nullable reference type feature, how can I tell if the type signature for a field/method/ property etc is a nullable or non-nullable reference type at runtime?

like image 552
Craig Smitham Avatar asked Nov 08 '22 04:11

Craig Smitham


1 Answers

In runtime you should be able to check that by checking custom attributes. This is how current prototype captures this information. But I guess until it's released something can still change. Take a look at answer to this question in official C# language design repo provided by yaakov.

like image 159
Krzysztof Branicki Avatar answered Nov 12 '22 00:11

Krzysztof Branicki