Given:
A string dayCodes
(i.e. \"MWF\"
or \"MRFU\"
) that I need to split and create a collection of strings so I
Just using char.ToString()
would work:
var daysArray = days.ToCharArray().Select( c => c.ToString()).ToArray();
Alternatively, and a better solution in my mind why don't you use the string directly with a dictionary for the mapping:
var daysArray = days.Select( c => dayMapping[c]).ToArray();
with dayMapping
just a Dictionary
that maps to the full day name:
Dictionary dayMapping = new Dictionary()
{
{ 'M', "Monday" },
{ 'T', "Tuesday" }
//and so on
}