Your stringArray
contains less than two elements.That is your problem, you need to make sure it contains at least two elements before switch
statement.BTW, if you just want to append a dot
to the end, you don’t need String.Split
, just use Insert
method:
string str = row["Version"].ToString();
str = str.Insert(str.Length, ".");
switch(str)
{
...
}
Or simply use string concatenation: string str = row["Version"].ToString() + "."
;
2
solved Error: System.IndexOutOfRangeException: Index was outside the bounds of the array [duplicate]