Guest User

Untitled

a guest
Jan 19th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. const string formatString = "yyyyMMdd HHmmss";
  2.  
  3. dtos = File.ReadAllLines(fileName.FullName)
  4. .Skip(1)
  5. .Select(line => new {line, columns = line.Split(';')})
  6. .Select(t =>
  7. {
  8. try
  9. {
  10. return new Foo
  11. {
  12. Bar = DateTime.ParseExact(t.columns[0], formatString, CultureInfo.InvariantCulture, DateTimeStyles.None)
  13. };
  14. }
  15. catch (FormatException)
  16. {
  17. Console.WriteLine("{0} is not in the correct format.", t.columns[0])
  18. }
Add Comment
Please, Sign In to add comment