Get the Day of a week from integer value of the Day

try below code :-

Response.Write(Enum.GetName(typeof(DayOfWeek),5));

Output:

Friday

and If you have to convert integers to days of week, see following sample to convert “2,4,5″ using LINQ.

var t = string.Join(",",
                 from g in "2,4,5".Split(new char[] { ',' })
                 select Enum.GetName(typeof(DayOfWeek), Convert.ToInt32(g)));
        Response.Write(t);

Output:

Tuesday,Thursday,Friday

For extra informations :-

http://msdn.microsoft.com/en-us/library/system.enum.getname(v=vs.110).aspx

Leave a Comment