This error will be shown when you try to access a array location which is not available at runtime. This can be due to the array not being given the appropriate values or it just receives a value which is not expected.
Before accessing any index of the array do a check with the following property:
array.Length
Example:
string[] array = new string[] { yourInput.ToString() };
string text = string.Empty;
if(array.Length > 0)
text = array[0];