mercredi 25 mai 2022

How to get default value for runtime object

I did a little reflection code.

var objValue = objType.GetProperty(propertyName)!.GetValue(obj, null);
if (objValue == default) // doesn't work for structures
    continue;

But the equal operator doesn't work for structures. How to fix it?





Aucun commentaire:

Enregistrer un commentaire