2

これが私の行動です:

public ActionResult List()
        {
            var currentDate = DateTime.Now;
            var list = new List<ArchiveViewModel>();
            for (var startDate = new DateTime(2012, 11, 1); startDate <= currentDate; startDate = startDate.AddMonths(1))
            {
                list.Add(new ArchiveViewModel
                {
                    Month = startDate.Month,
                    Year = startDate.Year,
                    FormattedDate = startDate.ToString("MMMM, yyyy")
                });
            }
            return View("List",list);
        }

これがビューです

@model IList<Blog.Web.UI.ViewModels.ArchiveViewModel>

    @foreach (var item in Model)
    {

            @Html.ActionLink(item.FormattedDate, "Post", "Archive", new { month = item.Month, year = item.Year }, null)

    }

このアクション結果の出力は次のようになります

November, 2012
December, 2012
January, 2013
February, 2013
March, 2013
April, 2013
May, 2013
June, 2013

しかし、私はこのようなものを出力したい

  June, 2013
   May, 2013
  April, 2013
 March, 2013
...
November, 2012

どうやってやるの ??

4

3 に答える 3

0

var newList = list.Reverse();

于 2013-06-19T21:49:23.433 に答える