I'm trying to get the console to print the last word in the following string array and added the code below:
static void Main(string[] args)
{
string[] words = new string[]
{
"Richard",
"Of",
"York",
"Gave",
"Battle",
"In",
"Vain"
};
Console.WriteLine($"The last word is {words[^1]}");
}
The compiler throws the error
Invalid expression term '^' for the '^' operator.
Any help will be much appreciated.