• How to get days of week in c#

    Posted on May 31, 2012 by in Dotnet Tips & Tricks, Tips & Tricks

    public static System.Data.DataTable GetDaysOfWeek()
            {
                System.Data.DataTable dtDaysOfWeek = new System.Data.DataTable("DaysOfWeek");
                dtDaysOfWeek.Columns.Add("ID");
                dtDaysOfWeek.Columns.Add("Day");
               
                foreach (DayOfWeek val in Enum.GetValues(typeof(DayOfWeek)))
                {
                    dtDaysOfWeek.Rows.Add((int)val, val.ToString());
                }
    
                return dtDaysOfWeek;
            }
    
    Be Sociable, Share!
      Post Tagged with

    Written by

    View all articles by

    Email : [email protected]

    Leave a Reply