using System.Collections.Generic;
public static void Main()
Movie[] movies = new Movie[] { new Movie("Xenogenesis", 1978, "James Cameron"),
new Movie("E.T. The Extra-Terrestrial", 1982, "Steven Speilberg"),
new Movie("Twilight Zone: The Movie", 1983, "Steven Speilberg"),
new Movie("The Terminator", 1984, "James Cameron"),
new Movie("Empire of the Sun", 1987, "Steven Speilberg"),
new Movie("Ghosts of the Abyss", 2003, "James Cameron"),
new Movie("Shutter Island", 2010, "Martin Scorcese")};
group m by m.Producer into grp
where grp.Count() == (from q in movies
group q by q.Producer into grp2
orderby grp2.Count() descending
select grp2.Count()).FirstOrDefault()
Producers = string.Join(", ", tot.Select(x => x.Producer)),
Count = tot.Max(x => x.Count)
.GroupBy(x => x.Producer)
movies.GroupBy(y => y.Producer)
.OrderByDescending(y => y.Count())
Producers = tot.Aggregate(string.Empty, (curr, next) => curr + ((curr.Equals(string.Empty)) ? "" : ", ") + next.Producer),
Count = tot.Max(y => y.Count)
Console.WriteLine("The most common producer(s) are {0} with {1} movies"
Console.WriteLine("The most common producer(s) are {0} with {1} movies"
public string Name { get; set; }
public int Year {get; set; }
public string Producer {get; set; }
public Movie (string name, int year, string producer) {