diff --git a/CsvSerializerDotNet/Deserializer.cs b/CsvSerializerDotNet/Deserializer.cs index d87bb9b..de9cc4f 100644 --- a/CsvSerializerDotNet/Deserializer.cs +++ b/CsvSerializerDotNet/Deserializer.cs @@ -134,7 +134,10 @@ private int IndexOf(char[] array, char element, int startingIndex = 0) if (property == null) throw new CsvDeserializationExcepion("Public property '" + doc.Headers[i].Replace(" ", "") + "' not found in the given model"); else - property.SetValue(obj, Convert.ChangeType(r.Values[i].ToString(), property.PropertyType)); + { + Type propertyType = Nullable.GetUnderlyingType(property.PropertyType) ?? property.PropertyType; + property.SetValue(obj, Convert.ChangeType(r.Values[i].ToString(), propertyType)); + } } result.Add(obj);