Determine if reflected property can be assigned null

后端 未结 4 756
灰色年华
灰色年华 2020-12-15 16:15

I wish to automagically discover some information on a provided class to do something akin to form entry. Specifically I am using reflection to return a PropertyInfo value f

4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-15 16:42

    From http://msdn.microsoft.com/en-us/library/ms366789.aspx

    if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>))
    

    Type would be your PropertyInfo.PropertyType

提交回复
热议问题