I just started coding with C# and i keep getting this error 'Index was outside the bounds of the array.' and i dont know what i did wrong anyone able to help? I keep getting this message
Index was outside the bounds of the array.
I tried looking around but didnt find anything.
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
{
ChromeDriver driver = new ChromeDriver(@"C:\webdrivers");
//textbox input
// string quest = question1.Text;
//random choise
var random = new Random();
var Names = question1.Text.Split();
int index = random.Next();
//the error is here\\
string randomName = Names[index];
driver.FindElement(By.ClassName("whsOnd")).SendKeys(randomName);
}
private void Button_Click(object sender, RoutedEventArgs e)
{
ChromeDriver driver = new ChromeDriver(@"C:\webdrivers");
ChromeDriver drv; Thread th;
string url = "google.com";
driver.Navigate().GoToUrl(url);
}
}