dimanche 12 août 2018

Check if property is of type or it's nullable type

I am currently checking if a property type is a DateTime or a nullable DateTime like this:

if (prop.PropertyType == typeof(DateTime) || prop.PropertyType == typeof(DateTime?))

Can anyone please tell me if I can somehow condense this into a single statement by checking the underlying type?





Aucun commentaire:

Enregistrer un commentaire