How to distinguish values โโof type value, nullable value-type, enum, nullable-enum, reference-types through reflection?
enum MyEnum { One, Two, Three } class MyClass { public int IntegerProp { get; set; } public int? NullableIntegerProp { get; set; } public MyEnum EnumProp { get; set; } public MyEnum? NullableEnumProp { get; set; } public MyClass ReferenceProp { get; set; } } class Program { static void Main(string[] args) { Type classType = typeof(MyClass); PropertyInfo propInfoOne = classType.GetProperty("IntegerProp"); PropertyInfo propInfoTwo = classType.GetProperty("NullableIntegerProp"); PropertyInfo propInfoThree = classType.GetProperty("EnumProp"); PropertyInfo propInfoFour = classType.GetProperty("NullableEnumProp"); PropertyInfo propInfoFive = classType.GetProperty("ReferenceProp"); propInfoOne.??? ............... ............... } }
Where in propInfo ... can this data be obtained?
source share