I have the following method, which works perfectly.
//private static IEnumerable<object> movieSequence;
private static void DeferredExecution()
{
var movieSequence = new[] {
new {Name="Harry potter", Genre="Action/Thrill", ReleasedYear=2011, Price=24.0},
new {Name="Tooth fairy", Genre="Family", ReleasedYear=2010, Price=20.5},
new {Name="How to train your dragon", Genre="Family", ReleasedYear=2010, Price=20.5}
};
double priceMultiplier = 0.5;
var newPriceList = movieSequence.Select(movie => new
{
Name = movie.Name,
Genre = movie.Genre,
ReleasedDate = movie.ReleasedYear,
Price = movie.Price * priceMultiplier
});
foreach (var movie in newPriceList)
{
Console.WriteLine("{0} ({1}) costs ${2}", movie.Name, movie.ReleasedDate, movie.Price);
}
}
But, I want to extend the scope of movieSequence. Since it is of anonymous array type, its type couldn't be pin pointed.
IEnumerable doesn't work since T can't be specified, object in place of T couldn't bring movie.Name, movie.Genre etc.
Non-generic IEnumerable doesn't have Select extension.
IList, ICollection (parents of array) etc. doesn't have Select extension. Obviously "var" is not an option at the class level.
What could be the possible type?