Voglio usare reflection per ottenere il tipo di proprietà. questo è il mio codiceOttieni PropertyType.Name in reflection da tipo Nullable
var properties = type.GetProperties();
foreach (var propertyInfo in properties)
{
model.ModelProperties.Add(
new KeyValuePair<Type, string>
(propertyInfo.PropertyType.Name,
propertyInfo.Name)
);
}
questo codice propertyInfo.PropertyType.Name
è ok, ma se il mio tipo di proprietà è Nullable
ottengo questa stringa Nullable'1
e se scrivere FullName
se ottenere questo stirng System.Nullable1[[System.DateTime, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]
E 'un Nullable? –
E qual è la stringa che vuoi ottenere? Sembra che dovrai usare le proprietà/i metodi su PropertyType che ti consente di accedere ai parametri generici del tipo. –
http://stackoverflow.com/questions/5174423/getting-basic-datatype-rather-than-weird-nullable-one-via-reflection-in-c-sha – TheNextman