static void Main(string[] args) { MusicalArtist[] MusicalArtists = new MusicalArtist[1000]; MusicalArtists MusicalArtistsObject = new MusicalArtists(); Int32 NumberOfListsArtistNeedsToBeOn = 0; String LocationOfFiles = ""; // Process any external arugments passed into this application // Argument 1 is the number of lists that a musical artists must be in to be included as a pairing in the output file if (args.Count() >= 1) { NumberOfListsArtistNeedsToBeOn = Int32.Parse(args[0]); } else { // 200 seems to be a good number to set it at from my testing // If this number is too high, the possibility of valid pairings will be absent from the output file // If this number is too low, the possbility of invalid pairings will be present in the output fule NumberOfListsArtistNeedsToBeOn = 200; } // Argument 2 allows one to set where the input and output files are located if (args.Count() >= 2) { LocationOfFiles = args[1]; } else { LocationOfFiles = @"C:\Temp\"; } // All the reading of the file and setting up the data is done in this method MusicalArtists = MusicalArtistsObject.GetMusicalArtistsFromFile(LocationOfFiles); // All the writing to the output file is done in this method MusicalArtistsObject.WriteMusicalArtistsPairsToFile(MusicalArtists, NumberOfListsArtistNeedsToBeOn, LocationOfFiles); MusicalArtistsObject.HaltProgram(LocationOfFiles); }
private MusicalArtist[] SetUpDataStructures(List <String> lstOfUniqueArtistsInFile, List <String> lstOfArtistsDumpInFile) { Int32 i = 0; // Create the number of MusicalArists data structures needed based on the number of unique/distinct artists in the input file MusicalArtist[] MusicalArtists = new MusicalArtist[lstOfUniqueArtistsInFile.Count]; // Populate the data structures. One data structure per unique artist read in the input file. foreach (var artist in lstOfUniqueArtistsInFile) { MusicalArtist MusicalArtist = new MusicalArtist { Name = artist, NumberOfListsItsIn = lstOfArtistsDumpInFile.Where(x => x.Equals(artist)).Count() }; // Stash this one musical artist data structure in the array of musical artist data structures MusicalArtists[i] = MusicalArtist; i++; } return(MusicalArtists); }