Advertisement
Guest User

Untitled

a guest
Apr 1st, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. foreach (string line in File.ReadLines(path, Encoding.Default))//считываем строки файла, чтобы найти строки, содержащие заданные строки. Encoding.Default - (При отсутствии - знак кирилицы будет считываться как � )Получает кодировку для текущей кодовой страницы ANSI операционной системы.
  2. {
  3. if (line.Contains(selectedAuthor))
  4. {
  5. if(Convert.ToInt32(line.Substring(line.IndexOf(':',0)+1)) >= fromYear)
  6. {
  7. books.Add(line);
  8. }
  9.  
  10. }
  11. }
  12.  
  13. public class Book
  14. {
  15. public string Title
  16. {
  17. get;
  18. set;
  19. }
  20.  
  21. public string Author
  22. {
  23. get;
  24. set;
  25. }
  26.  
  27. public int PublicationYear
  28. {
  29. get;
  30. set;
  31. }
  32. }
  33.  
  34. public static Book ParseBook(string str)
  35. {
  36. // Implementation
  37. }
  38.  
  39. var books = File.ReadLines(path, Encoding.Default).Select(ParseBook);
  40. var booksWrittenBySelectedAuthor = books.Where(b => b.Author == selectedAuthor).OrderBy(b => b.PublicationYear).ToList();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement