mardi 4 août 2015

Given a string with day of week, return integer

Is there a way to have something like:

string day = "Sunday";
int num = getDayOfWeek(day); //returns 0

I understand we could something like, and I wanted the reverse:

int num = 0;

//returns "Sunday"
System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.DayNames[(int)i] 

The easiest way would probably be to implement a dictionary that does what I am asking, but I wonder if there is something in C# DateTime functions that already does so for me.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire