Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. namespace musicplaylistanalyzer
  2. {
  3. class Program
  4. {
  5. static void Main(string[] args)
  6. {
  7.  
  8.  
  9.  
  10.  
  11. if (args != null && args.Length > 0)
  12. {
  13. using (StreamReader sr = File.OpenText(args[0]))
  14. {
  15. var lines = File.ReadAllLines(args[0]).Select(x => x.Split('\t'));
  16. string line;
  17. Song[] songs = {new Song("Name", "Artist", "Album", "Genre", 0, 0, 0, 0)};
  18.  
  19. int count = 0;
  20. while ((line = sr.ReadLine()) != null)
  21. {
  22. Console.WriteLine(count);
  23. // split the line of text into a collection
  24. string[] items = line.Split('\t');
  25. int[] i = { Int32.Parse(items[4]), Int32.Parse(items[5]), Int32.Parse(items[6]), Int32.Parse(items[7]), };
  26. songs[count] = new Song(items[0], items[1], items[2], items[3], i[0],i[1], i[2],i[3]); //This is where the code is breaking.
  27. count = count + 1;
  28.  
  29.  
  30. }
  31. Console.WriteLine("Songs with over 200 plays:\n");
  32. var songsOverTwoHundredPlays = from song in songs where song.Plays > 200 select song;
  33. foreach (var title in songsOverTwoHundredPlays)
  34. {
  35. Console.WriteLine(title);
  36. }
  37. }
  38. }
  39.  
  40. Console.ReadLine();
  41. }
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement