mercredi 18 juillet 2018

Null reference on reflection propertyinfo.getvalue

I have this code snippet

foreach ( var pinfo in prefilledData.GetType().GetProperties() ) {
   if ( pinfo.Name.ToLower() == "xxxxxx" )
     var g = pinfo.GetValue( prefilledData ).ToString();
}

but I am getting an error at pinfo.GetValue( prefilledData ).ToString();

System.NullReferenceException: Object reference not set to an instance of an object





Aucun commentaire:

Enregistrer un commentaire