1.

Given is the code of days(example: MTWTFSS ) which i need to split and hence create a list of days of week in strings(example: Monday , Tuesday , Wednesday , Thursday , Friday , Saturday , Sunday ). A set of code is given for this purpose but there is error ocuring in that set of code related to conversion of char to strings.Hence,Select a code to solve the given error.
static void Main(string[] args) { var days = "MTWTFSS"; var daysArray = days.ToCharArray().Cast().ToArray(); for (var i = 0; i < daysArray.Length; i++) { switch (daysArray[i]) { case "M": daysArray[i] = "Monday"; break; case "T": daysArray[i] = "Tuesday"; break; case "W": daysArray[i] = "Wednesday"; break; case "R": daysArray[i] = "Thursday"; break; case "F": daysArray[i] = "Friday"; break; case "S": daysArray[i] = "Saturday"; break; case "U": daysArray[i] = "Sunday"; break; } } daysArray[daysArray.Length - 1] = "and " + daysArray[daysArray.Length - 1]; Console.WriteLine(string.Join(", ", daysArray)); } 

A. Var daysArray = new List();
B. Var daysArray = days.Select(c =&gt;dayMapping[c]).ToArray();
C. Var daysArray = days.ToCharArray().Select(c =&gt;c.Tostring()).ToArray();
D. None of above mentioned.
Answer» D. None of above mentioned.


Discussion

No Comment Found