Possible Duplicate:
Detecting a Nullable Type via reflection
I have this code :
string type = string.Empty;
PropertyInfo[] propertyInfos = typeof(T).GetProperties();
foreach (var item in propertyInfos)
if (item.Name.ToUpper() == searchField.ToUpper())
{
type = item.PropertyType.FullName;
break;
}
switch (type)
{
case "System.Int32":
//...
break;
case "System.Single":
//...
break;
}
The code works but the problem is when the type is a nullable. How know if the type is a nullable ? The nullable type (int32? long? double?) and how convert a string into this nullable type ?
Thanks,