Can someone tell me why i am getting an error?

 if (userChoice == "a" || userChoice == "A") { Console.WriteLine("==============================================="); Console.WriteLine("Please enter your Full Name (e.g. Bruce Wayne):\n"); string userName = Console.ReadLine(); string[] words = userName.Split(' '); string firstName = words[1]; string lastName = words[2]; Console.WriteLine("Your first name is: " + firstName + " Your last name is: " + lastName); } 

I want to take the users input (the name) and split it into two separate strings then display them. But, i keep getting a System.IndexOutOfRangeException error. Please help 🙂 I apologize for terrible formatting.

by Gossamer195 via /r/csharp

Leave a Reply