Stop at End of array or list

I’m making a script that reads through an array or list and I want it to stop wen there are no more variables to pull from instead of crashing wen there is nothing left to read

I’m forcing it to stop reading my float array by converting it to a string array or list and adding the word “stop” at the end and stoping wen it reads this before it teaches the end

I’m looking for a clean way of achieving this in c#

//Update through array list play black
If(stringArray == "stop"){
readArrayIO = false;
}

Compare the current integer index to stringArray.Length. If index < array.Length, you’re fine to keep going. If index >= array.Length, you should stop.

Edit: Consider perusing the documentation to stumble learn about other useful properties and methods, especially when you’re stuck with a problem and looking for a solution.

2 Likes