Closed frankcollins3 closed 1 year ago
string[] pallets = { "B14", "A11", "B12", "A13" }; 👍 Array.Clear(pallets, 0, 1); check: check: A11 check: B12 check: A13
👍 check B14 // gone.
also proposed approach. not specifying 3 but specifying Array.Length - 1; [7:22am]
👍 Array.Clear(pallets, 0, pallets.Length -1);
-- A13 check: check: check: 👍 check: A13 [7:24am]
attempting to do: string[] pallets = { "B14", "A11", "B12", "A13" }; void showPallets() { foreach(string p in pallets) { Console.Write($"check: \t {p} \n "); } } // Array.Clear(pallets, 0, 2);
error: Array.Clear(pallets, 2, 3); Unhandled exception. System.IndexOutOfRangeException: Index was outside the bounds of the array.
proposed approach: confused how index is out of bounds of array if the array index ends at [3] and so does Array.Clear()
possible improvements: use array properties to gather index, not explicitly define/guess with hard coded int