I need to Produces a sequence of strings representing the string version of a sequence of integers using LINQ Select or SelectMany keyword
Thank You in advance!
I need the output to be:
"five",
"four",
"one",
"three",
"nine",
"eight",
"six",
"seven",
"two",
"zero",
update:
Solved Thank to Maciej Los
int[] numbers = {5, 4, 1, 3, 9, 8, 6, 7, 2, 0};
string[] strings = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
IEnumerable<string> stringSequence = numbers.Select(x => strings[x]).ToList();
return stringSequence;
What I have tried:
public static void Main(string[] args)
{
int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
string[] strings = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" };
IEnumerable<string> stringSequence = numbers.Select((n, index) => n.ToString == strings[index]);
IEnumerable<string> stringSequence = numbers.Select(x => x.ToString());
Console.WriteLine(stringSequence);
}