I’m not able to assign a generic list to ViewBag. Here is my code:
var m = from i in Enumerable.Range(0, 12)
let now = DateTime.Now.AddMonths(i)
select now.ToString("MMMM") + " " + now.Year.ToString();
ViewBag.b = m;
I am getting this when I output the ViewBag value:
System.Linq.Enumerable.WhereSelectEnumerableIterator<int,string>
You can cast it to a list like this:
And then in your view: