0

I want to perform some action if a value of a property is default or null by reflection. The following code gives "is a variable but is used like a type error" on default(t).

foreach(var p in dummyModel.GetType().GetProperties())
{
  var value = p.GetValue(dummyModel,null);
  var t = p.PropertyType;
  if(value != default(t)
  {
    //some action here
  }

}

bugrasitemkar
  • 431
  • 1
  • 7
  • 26

0 Answers0