[c#][Reflexion] Obtenir le type d'un generic
Salut, jai ce petit bout de code
Code:
1 2 3 4 5 6 7 8 9 10 11 12
|
CouponsEntity = new DataTable("Coupons");
foreach (PropertyInfo propertyInfo in typeof(Business.Model.ICoupon).GetProperties())
{
Type type = propertyInfo.PropertyType;
if (type.FullName.IndexOf(typeof(Nullable).FullName) != -1)
type = type.GetGenericArguments()[0];
CouponsEntity.Columns.Add(propertyInfo.Name, type);
} |
Je voudrais savoir si qqn sait comment obtenir le type d'un generic (nullable, list etc)
J'ai utiliser ce bout de code pour l'obtenir mais je trouve pas cela très propre
Code:
if (type.FullName.IndexOf(typeof(Nullable).FullName) != -1)
merci