0

I have a CSV file that I would like to read into a list in a C# code, for that matter I have used the CsvHelper package. The CSV file contains a DateTime column which can be invalid for some rows and would have the value: "00.00.0000" I am using the attribute : [DateTimeStyles(0)] which correctly converts the valid DateTime values, however I am having an exception when the value within the file is incorrect.

I would like to know if there is a way to ignore the rows with such values using attributes or if I would have to override the DateTimeStyles attribute itself.

Here is the class I am using to map the data:

class CsvRow
    {        
        public String field1{ get; set; }

        [DateTimeStyles(0)]
        public DateTime DateTimeFieldToConvert { get; set; }
}
Claritta
  • 189
  • 1
  • 4
  • 17

0 Answers0