static void Main(string[] args) { Movie_Rental mr = new Movie_Rental($"C:\\Users\\Student\\git\robrosin-c\\module-1\\Assessment\\student-assessment\\Assessment\\Data\\MovieInput.csv"); foreach (KeyValuePair <string, Movie_Rental> field in mr.MovieInfo) { Console.WriteLine($"{field.Key} {field.Value.Title}, {field.Value.Format}, {field.Value.PremiumMovie}"); } }
public Movie_Rental(string title, string format, bool premiumMovie) { MovieInfo = new Dictionary <string, Movie_Rental>(); using (System.IO.StreamReader rdr = new StreamReader(path)) { string[] movieDetail; string line = ""; while (!rdr.EndOfStream) { line = rdr.ReadLine(); movieDetail = line.Split(","); Movie_Rental movie = new Movie_Rental(movieDetail[0], movieDetail[1], bool.Parse(movieDetail[2])); MovieInfo.Add(movie.Title, movie); } } }