Creating a Month Dropdown in C# ASP.NET MVC

Posted by Chris M on Stack Overflow See other posts from Stack Overflow or by Chris M
Published on 2010-05-26T09:39:14Z Indexed on 2010/05/26 9:41 UTC
Read the original article Hit count: 166

Filed under:
|
|

This method seems stupid and a bit heavy; is there a more optimal way of creating the same thing (its for an MVC View Dropdown)

private List<KeyValuePair<int, string>> getMonthListDD
{
    get
    {
        var dDur = new List<KeyValuePair<int, string>>();
        dDur.Add(new KeyValuePair<int, string>(1, "January"));
        dDur.Add(new KeyValuePair<int, string>(2, "Febuary"));
        dDur.Add(new KeyValuePair<int, string>(3, "March"));
        dDur.Add(new KeyValuePair<int, string>(4, "April"));
        dDur.Add(new KeyValuePair<int, string>(5, "May"));
        dDur.Add(new KeyValuePair<int, string>(6, "June"));
        dDur.Add(new KeyValuePair<int, string>(7, "July"));
        dDur.Add(new KeyValuePair<int, string>(8, "August"));
        dDur.Add(new KeyValuePair<int, string>(9, "September"));
        dDur.Add(new KeyValuePair<int, string>(10, "October"));
        dDur.Add(new KeyValuePair<int, string>(11, "November"));
        dDur.Add(new KeyValuePair<int, string>(12, "December"));

        return dDur;
    }
}

© Stack Overflow or respective owner

Related posts about c#

Related posts about asp.net-mvc