4 Replies
line for error is string toppings = temp.Substring(temp.IndexOf(","), temp.IndexOf("£"));
its saying my indexes for the substring are invalid
this is the temp variable
Margherita, tomato sauce, cheese £5.00
im trying to take a substring from
temp.IndexOf(",") = 33
temp.IndexOf("£") = 38
selectionItems is a list where each of these have been added as separate items
IndexOf returns the first occurrence of a char in your case '','' for this 10 and for "£" 33 substring takes the startindex and length so when your string is 38chars long it results into a OutOfRangeException
Idk what you exactly want you want all the toppings or only the last one
yh i thought it was 1st value index to 2nd value index and substring is characters between
only just realised it was starting index and length
lol