to button.variableName = games.Substring(games_.IndexOf(‘?’) + 1, games*.Length - 1); Anyway i think indexOf(‘?’) + 1 can be a problem, are you sure the ‘?’ cant be found at the end of the string? If the ? is at the end it can go out of the string EDIT: As bunny83 said, the for (int i = 0; i <= games.Length; i++) is wrong because “i” will be games.Length and it will cause a index-out-of-bounds exception. indexOf returns -1 if it failed the search (the string dont have the char)… maybe its the problem? (I cant comment)*_
Is likely to cause an ArgumentOutOfRangeException. When calling string.Substring(), you need to make sure that startIndex plus length indicates a valid index in the string.