using System; using System.Collections.Generic; using System.Globalization; namespace ConsoleApp1 { class Program { static void Main(string[] args) { Console.WriteLine("How many movies you would like to create?"); var value = int.Parse(Console.ReadLine()); List<Movie> movieList = new List<Movie>(); for(int i = 1;i <= value;i++) { Movie m = new Movie(); Console.WriteLine("Movie Number #" + i); Console.WriteLine("Title of the Movie?"); m.title = Console.ReadLine(); Console.WriteLine("A little overview?"); m.overview = Console.ReadLine(); Console.WriteLine("Which genres the movie is in?"); m.genre = Console.ReadLine().Split(' '); Console.WriteLine("What is the release date of the movie?"); m.releaseDate = Console.ReadLine(); Console.WriteLine("-------------------------------------------------"); movieList.Add(m); } Console.WriteLine("The List of movies you have added"); for (int i = 0; i < movieList.Count; i++) { Console.WriteLine("Movie Number : #" + (i+1)); Console.WriteLine("Movie Title : " + movieList[i].title); Console.WriteLine("Movie Overview : " + movieList[i].overview); Console.WriteLine("Movie Genre : " + string.Join(" | ", movieList[i].genre)); Console.WriteLine("Movie ReleaseDate : " + movieList[i].releaseDate); Console.WriteLine("-------------------------------------------------"); } Console.Read(); } } class Movie { public string title { get; set; } public string overview { get; set; } public string[] genre { get; set; } public string releaseDate { get; set; } } }
Standard input is empty
How many movies you would like to create?
Unhandled Exception: System.ArgumentNullException: Value cannot be null. Parameter name: String at System.Number.StringToNumber (System.String str, System.Globalization.NumberStyles options, System.Number+NumberBuffer& number, System.Globalization.NumberFormatInfo info, System.Boolean parseDecimal) [0x00006] in <8f2c484307284b51944a1a13a14c0266>:0 at System.Number.ParseInt32 (System.String s, System.Globalization.NumberStyles style, System.Globalization.NumberFormatInfo info) [0x00014] in <8f2c484307284b51944a1a13a14c0266>:0 at System.Int32.Parse (System.String s) [0x00007] in <8f2c484307284b51944a1a13a14c0266>:0 at ConsoleApp1.Program.Main (System.String[] args) [0x0000f] in <ce449b704fc24623b8dfd7ea83199377>:0 [ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentNullException: Value cannot be null. Parameter name: String at System.Number.StringToNumber (System.String str, System.Globalization.NumberStyles options, System.Number+NumberBuffer& number, System.Globalization.NumberFormatInfo info, System.Boolean parseDecimal) [0x00006] in <8f2c484307284b51944a1a13a14c0266>:0 at System.Number.ParseInt32 (System.String s, System.Globalization.NumberStyles style, System.Globalization.NumberFormatInfo info) [0x00014] in <8f2c484307284b51944a1a13a14c0266>:0 at System.Int32.Parse (System.String s) [0x00007] in <8f2c484307284b51944a1a13a14c0266>:0 at ConsoleApp1.Program.Main (System.String[] args) [0x0000f] in <ce449b704fc24623b8dfd7ea83199377>:0