I have converted several days of the week to their respective integer values..
For example: Tuesday, Thursday, Friday
As 2,4,5
Now I need to get back to the days from the integers.
Simply the inverse of what i had done.
Inverse of the Question: Get Integer value of day of week
Is there a simple standard way for getting day of week from integer value in C# or else I will have to perform a manual calculation with a Method?
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