Given:
A string dayCodes
(i.e. \"MWF\"
or \"MRFU\"
) that I need to split and create a collection of strings so I
You can do this:
var dayCode = "MWF";
var daysArray = new List();
var list = new Dictionary{
{"M", "Monday"},
{"T", "Tuesday"},
{"W", "Wednesday"},
{"R", "Thursday"},
{"F", "Friday"},
{"S", "Saturday"},
{"U", "Sunday"}
};
for(int i = 0,max = dayCode.Length; i < max; i++)
{
var tmp = dayCode[i].ToString();
if(list.ContainsKey(tmp))
{
daysArray.Add(list[tmp]);
}
}
Console.WriteLine(string.Join(",", daysArray));
Output: