I am trying to solve an online challenge in an efficient way. I have to basically output a string in a certain format given an array of int.
I have to make the string look like : (123) 456-7890 (the input array is guaranteed to be correct length).
I found out about the new C# indices and ranges and tried something like this:
public static string GenerateOutput(int[] numbers)
{
return $"({numbers[0..2]}) {numbers[3..5]}-{numbers[6..9]}";
}
But that doesn't return the desired result. How can I transform them to strings and return the correct output?